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 |
贴代码#include<iostream> #include<cstring> using namespace std; int big,d[4][100],k,m,n,s; int a[3]; void add() { int p=0; for(int i=0;i<big;i++) { d[s][i]=d[k][i]+d[m][i]+d[n][i]+p; if(d[s][i]>9) {p=d[s][i]/10;d[s][i]=d[s][i]%10;} else p=0; } if(p) {d[s][big]=p;big++;} } void f() { int l[5],p=0,j=-1; for(int i=0;i<3;i++) {j=-1; while(a[i]!=0) { d[i][++j]=a[i]%10; a[i]/=10; } } for(int i=0;i<3;i++) { for(int j=0;j<5;j++) { if(d[i][j]!=0) {p=j;continue;} } if(big<p) big=p; } big++; for(int i=0;i<97;i++) { k=i%4; m=(i+1)%4; n=(i+2)%4; s=(i+3)%4; add(); } } int main() { while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF) { big=0; f(); for(int i=0;i<big;i++) cout<<d[s][big-i-1]; cout<<endl; for(int i=0;i<4;i++) for(int j=0;j<100;j++) d[i][j]=0; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator