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 |
楼下给的数据,有几个这个程序测试不过去,但是可以ACIn Reply To:断断续续花了几天的时间,终于AC了,纪念一下0MS,分享一下代码(虽然有些部分是参考别人的)的) Posted by:fegar at 2011-08-13 15:06:28 > #include <stdio.h> > #include <string.h> > int result[153]; > int strl=5; > int tranform(char *s1,int *s2) > { > int i,j; > for(j=4,i=0;s1[i]!='\0';i++) > if(s1[i]!='.'){ > s2[j--]=s1[i]-'0'; > } > j=0; > while(s1[j]!='.'&&s1[j]!='\0') > j++; > return 5-j; > } > void mul(int *s3,int a) > { > int i,j,s4[153]={0}; > for(i=0;i<5;i++) > for(j=0;j<strl;j++) > s4[i+j]+=s3[i]*result[j]; > strl=i+j; > for(i=0;i<strl;i++){ > result[i]=s4[i]%10; > s4[i+1]+=s4[i]/10; > } > if(a>=1) > mul(s3,a-1); > } > main() > { > int i,j,k,n,bit,s[5]={0}; > char R1[7]; > while(scanf("%s%d",R1,&n)!=EOF){ > if(n==0) > printf("1"); > else{ > bit=tranform(R1,s); > for(i=0;i<5;i++) > result[i]=s[i]; > if(n>1) > mul(s,n-2); > bit=n*bit; > for(i=strl-1,j=0;result[i]==0&&i>bit-1;i--) > j++; > for(i=0,k=0;result[i]==0&&i<=bit-1;i++) > k++; > for(i=strl-1-j;i>bit-1;i--) > printf("%d",result[i]); > if(k!=bit) > printf("."); > for(i=bit-1;i>=k;i--) > printf("%d",result[i]); > printf("\n"); > strl=5; > } > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator