| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
疑问自己做1003题,在自己机子上试了很多遍,都有正确的结果,为什么一提交就是wrong answer?
源程序如下(C++):
#include<iostream>
using namespace std;
float fun(int n) {
float sum=0;
int term=2;
while(term<=n){
sum+=1.0/term;
term++;
}
return sum;
}
int main (void) {
float a[1000];
int n=0,j=0;
for( j=0;j<1000;j++){
cin>>a[j];
n++;
if(a[j]==0.00)
break;
}
for(j=0;j<n;j++) {
if((a[j]<=0.50)&&(a[j]>=0.01))
cout<<"1 cards"<<endl;
else if((a[j]<=5.20)&&(a[j]>=0.50)){
for(int i=2;i<1000;i++){
if((a[j]<=fun(i+1))&&(a[j]>=fun(i)))
cout<<i<<"cards"<<endl;
}
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator