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 n,i,b[151],x,y,k,a[5],shi,c[151],d[151],e[151],f[151],end,begin,m,s; char q[6]; main() { while(scanf("%s%d",q,&n)==2) { m=-1; s=strlen(q); while(s<6) { q[5]=q[4]; q[4]=q[3]; q[3]=q[2]; q[2]=q[1]; q[1]=q[0]; q[0]='0'; s=strlen(q); } for(i=0;i<=150;i++) a[i]=b[i]=c[i]=d[i]=e[i]=f[i]=0; k=-1; for(i=4;i>=0;i--) { k++; b[i]=q[k]-48; if(b[i]==-2) { y=k; y=(5-y)*n; i++; m=1; } } if((q[5]-48)==-2) { m=1; y=0; } if(m!=1) { y=0; for(i=5;i>=1;i--) b[i]=b[i-1]; b[0]=q[5]-48; } if(b[4]==b[3]==b[2]==b[1]==b[0]==0) b[0]=q[5]-48; for(i=0;i<=4;i++) a[i]=c[i+1]=d[i+2]=e[i+3]=f[i+4]=b[i]; for(k=2;k<=n;k++) { x=0; for(i=0;i<150;i++) { shi=(x-x%10)/10; x=b[i]*a[0]+shi; b[i]=x%10; } x=0; for(i=1;i<150;i++) { shi=(x-x%10)/10; x=c[i]*a[1]+shi; c[i]=x%10; } x=0; for(i=2;i<150;i++) { shi=(x-x%10)/10; x=d[i]*a[2]+shi; d[i]=x%10; } x=0; for(i=3;i<150;i++) { shi=(x-x%10)/10; x=e[i]*a[3]+shi; e[i]=x%10; } x=0; for(i=4;i<150;i++) { shi=(x-x%10)/10; x=f[i]*a[4]+shi; f[i]=x%10; } x=0; for(i=0;i<=150;i++) { shi=(x-x%10)/10; x=b[i]+c[i]+d[i]+e[i]+f[i]+shi; b[i]=x%10; } for(i=0;i<=150;i++) f[i+4]=e[i+3]=d[i+2]=c[i+1]=b[i]; } for(i=0;i<=150;i++) if(b[i]!=0) { begin=i; break; } for(i=150;i>=y;i--) { if(b[i]!=0) { end=i; break; } if(b[y]==0) end=y-1; } if(y==0) begin=0; if(y<begin) begin=y; for(i=end;i>=begin;i--) { if(i==(y-1)) printf("."); printf("%d",b[i]); } 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