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 |
WA,帮帮忙吧#include<iostream.h> int a[6],result[127],temp[127]; void main() { char s[7]; int n; while(cin>>s>>n) { int pp=-1,carry=0,op,ed,b=0; int j=5; for(int i=5;i>=0;i--) { if(s[i]=='.') pp=i; else { a[j]=s[i]-'0'; j--; } } if(pp!=-1) pp=126-(5-pp)*n; for(i=0;i<6;i++) result[126-i]=a[5-i]; for(i=1;i<n;i++) { for(int m=5;m>=0;m--) { for(int n=126;n>=5;n--) { int t=temp[n+m-5]; temp[n+m-5]=(t+result[n]*a[m]+carry)%10; carry=(t+result[n]*a[m]+carry)/10; } carry=0; } for(m=0;m<=126;m++) { result[m]=temp[m]; temp[m]=0; } } for(i=0;i<=126;i++) { if(result[i]!=0) { op=i; break; } else if(pp==i) { op=i; break; } } if(pp==-1) ed=126; else for(i=126;i>=0;i--) { if(pp==i) { ed=i; b=1; break; } else if(result[i]!=0) { ed=i; break; } } for(i=op;i<=ed;i++) { if(pp==i&&result[i]==0) { if(b==0) { cout<<'.'; continue; } } cout<<result[i]; if(i==pp&&b==0) cout<<'.'; } cout<<endl; for(i=0;i<=126;i++) result[i]=0; for(i=0;i<6;i++) a[i]=0; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator