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 |
喵了个咪的 实验证明数组至少开到107才能AC#include<stdio.h> #include<string.h> int main() { char a[107],sum[108];int i,j,len; for(i=0;i<107;i++)sum[i]=0; while(1) { scanf("%s",a); j=(len=strlen(a))-1; if(len==1&&*a==48)break; for(i=107;i>107-len;i--) sum[i]+=a[j--]-48; for(i=107;i>107-len;i--) sum[i-1]+=sum[i]/10,sum[i]=sum[i]%10; for(i=0;i<len;i++)a[i]=0; } for(i=107;i>1;i--) sum[i-1]+=sum[i]/10,sum[i]=sum[i]%10; for(i=0;i<108;i++) if(sum[i]!=0)break; if(i==108)putchar('0'); while(i<108) putchar(sum[i++]+48); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator