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 <stdio.h> #include <string.h> int main() { char r[8],w[8]; int a[8],b[155],s[155]; int c,f,i,j,k,l,m,n; while (scanf("%s%d",r,&n)!=EOF) { if (n==0){printf("1\n");continue;} j=m=f=0; for (i=0;i<155;++i) b[i]=s[i]=0; for (i=l=strlen(r)-1;i>=0;--i) { if (r[l-i]!='.') { w[j++]=r[l-i]; m++; } else {m=0;f=1;} } if (f) while (!(w[j-1]-'0')) {--j;--m;} for (i=l=j-1;i>=0;--i) a[i]=b[i]=w[l-i]-'0'; l=j; for (i=1;i<n;++i) { for (j=0;j<l;++j) for (k=0;k<(6*n+5);++k) s[j+k]+=a[j]*b[k]; for (k=0,c=0;k<(6*n+5);++k) { b[k]=(s[k]+c)%10; c=(s[k]+c)/10; s[k]=0; } } j=144; while (!b[j]) --j; l=j-m*n; if (f) { k=j; if ((l+1)<0) { printf("."); for (;l+1<0;l++) printf("0"); } else { for (k=j;k>=j-l;k--) printf("%d",b[k]); if (k>=0) printf("."); } for (;k>=0;--k) printf("%d",b[k]); } else { for (;j>=0;--j) printf("%d",b[j]); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator