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:wa 了无数次 郁闷 求高人指点In Reply To:wa 了无数次 郁闷 求高人指点 Posted by:1987 at 2005-03-30 10:49:28 > #include <iostream.h> > void fun(int,char[]); > void main() > { > char a[7]="0"; > int b; > while(cin.get(a,7)) > { > if(cin.get() == '\n') > return; > cin>>b; > fun(b,a); > while(cin.get() != '\n'); > } > } > void fun(int b,char a[7]) > { > long e; > int judge; > long d[150]; > e=0; > judge=5; > for(int i=0;i<6;i++) > { > if(a[i]!='.') > e=e*10+(a[i]-'0'); > else > judge=i; > } > judge=5-judge; > judge*=b; > > for(i=0;i<149;i++) > d[i]=0; > d[149]=1; > > for(i=0;i<b;i++) > { > for(int k=149;k>=0;k--) > d[k]=d[k]*e; > for(k=149;k>=0;k--) > { > if(k>=3) > { > d[k-3]+=d[k]/1000; > d[k]%=1000; > } > if(k>=2) > { > d[k-2]+=d[k]/100;d[k]%=100; > } > if(k>=1) > d[k-1]+=d[k]/10; > d[k]%=10; > } > } > > int m; > for(i=149;i>=0;i--) > { > if(d[i]!=0||judge==0) > { > m=i+1; > break; > } > } > int O=0; > /* for(int h=0;h<150;h++) > { > cout<<"d["<<h<<"]"<<d[h]; > }*/ > for(i=0;i<m;i++) > { > if(i==150-judge) > { > cout<<'.'; > O=1; > } > if(d[i]!=0||O) > { > O=1; > cout<<d[i]; > } > } > cout<<endl; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator