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 |
Who can help me?My C++ Code #include <iostream> int a[150],b[150],c[150]; using namespace std; void mul(){ int ac=0; for (int i=0;i<150;i++) c[i]=0; for (int i=0;i<150;i++){ ac=0; for (int j=0;j<5;j++){ c[i+j]+=b[i]*a[j]; ac=c[i+j]/10; c[i+j]%=10; c[i+j+1]+=ac; } } for (int i=0;i<150;i++) b[i]=c[i]; } void Orz(char *s,int n){ int i,f,l,ll; for (i=0;i<6;i++) a[i]=s[i]-'0'; for (i=0;i<n;i++) mul(); for (f=0;f<150;f++) if (c[f]) break; if (f==150) {cout<<0<<endl; return;}; for (l=150;l>=0;l--) if (c[l]) break; for (i=l;i>=f;i--) cout<<c[i]; for (ll=5;a[ll]==0;ll--); for (i=0;i<(5-ll)*n;i++) cout<<0; cout<<endl; } void calc(char *s,int n){ int i,j,k,pp,f,l; for (i=0;i<150;i++) b[i]=0; b[0]=1; c[0]=1; for (pp=0;pp<6;pp++) if (s[pp]=='.') break; if (pp==6) { Orz(s,n); return; } for (i=pp;i<5;i++) s[i]=s[i+1]; for (i=0;i<5;i++) a[i]=s[4-i]-'0'; for (i=0;i<n;i++) mul(); for (f=0;f<150;f++) if (c[f]!=0) break; if (f==150) {cout<<0<<endl; return;}; for (l=150;l>=(5-pp)*n;l--) if (c[l]) break; if (l==((5-pp)*n-1)) { cout<<'.'; for (i=l;i>=f;i--) cout<<c[i]; } else { if (f>(((5-pp)*n)-1)) { for (i=l;i>=(5-pp)*n;i--) cout<<c[i]; } else {for (i=l;i>=(5-pp)*n;i--) cout<<c[i]; cout<<'.'; for (i=(5-pp)*n-1;i>=f;i--) cout<<c[i]; } } cout<<endl; } int main(){ int n; char s[7]; while (cin>>s>>n) calc(s,n); return 0; } Thanks! Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator