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 |
100道AC 纪念~!!!yeah!~ ~注意 n^0=1 0^n=0;#include <stdio.h> #include <string.h> #define N 200 int main() { int i,j,k,t; int p,q,temp1,temp2; int n,l,sign,count; char s[100]; int a[N],sum[N],b[N]; while(scanf("%s%d",s,&n)!=EOF) { memset(b,0,N*sizeof(int)); memset(a,0,N*sizeof(int)); l=strlen(s); b[0]=1;sign=0; for(i=l-1,j=0,count=0;i>=0;i--) { if(s[i]!='.') { a[j]=s[i]-'0'; count=count+a[j]; j++; } else sign=j*n; } if(count==0) printf("0\n"); else if(n==0) printf("1\n"); else { for(i=1;i<=n;i++) { memset(sum,0,N*sizeof(int)); for(j=0;j<N;j++) { t=j; for(k=0,temp1=0,temp2=0;k<N;k++) { temp1=sum[t]+a[j]*b[k]+temp2; sum[t]=temp1%10; temp2=temp1/10; t++; } } for(j=0;j<N;j++) b[j]=sum[j]; } p=N-1;q=0; while(sum[p]==0) p--; while(sum[q]==0&&q!=sign) q++; if(p+1>sign) { if(sign==q) { for(i=p;i>=q;i--) printf("%d",sum[i]); } else { for(i=p;i>=q;i--) { if(i==sign&&sign!=0) printf("%d.",sum[i]); else printf("%d",sum[i]); } } } else { printf("."); for(i=sign-1;i>=q;i--) printf("%d",sum[i]); } printf("\n"); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator