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 |
Re:哪位高手给看一下吧,怎么是RE?给的数据都测过了In Reply To:哪位高手给看一下吧,怎么是RE?给的数据都测过了 Posted by:Greepry at 2008-11-20 21:41:45 > #include<iostream> > #include<cmath> > using namespace std; > int main() > { > char a; > double sum; > int i,j,s=1,num[50]; > while(s>0) > { > s=0; > for(i=0;;i++) > { > a=cin.get(); > if(a=='\n') break; > else > { > num[i]=a-48; > s+=num[i]; > } > } > if(s==0) break; > sum=0; > for(j=0;j<i;j++) sum+=num[j]*(pow((float)2,i-j)-1); > cout << sum << endl; > }; > system("pause"); > } 你这个1.system("pause")没必要吧,2.你求2^i的时候用浮点数有误差吧,你可以先把2^i存在一个整形数组中嘛,不放心的话用__in64或者用unsigned __int64嘛,不多, Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator