poj 3982(水题)
作者:互联网
#include<iostream> #include<cstring> using namespace std; int data[105][205],a[3],len[105]; void Plus(int i){ int k,l; for(k=i-3;k<i;k++){ for(l=0;l<len[k];l++){ data[i][l] += data[k][l]; if(data[i][l]>=10){ data[i][l+1] += data[i][l]/10; data[i][l] %= 10; } } while(data[i][l]>=10){ data[i][l+1] = data[i][l]/10; data[i][l] %= 10; l++; } if(data[i][l]>0)l++; len[i] = max(len[i],l); } } int main(){ while(scanf("%d%d%d",&a[0],&a[1],&a[2])==3){ memset(data,0,sizeof data); memset(len,0,sizeof len); for(int i=0;i<3;i++){ int j=0; while(a[i]>0){ data[i][j++] = a[i]%10; a[i]/=10; } len[i] = j; } for(int i=3;i<100;i++){ Plus(i); } for(int i=len[99]-1;i>-1;i--){ printf("%d",data[99][i]); } printf("\n"); } return 0; }
标签:10,水题,int,d%,len,++,poj,data,3982 来源: https://www.cnblogs.com/stevenzrx/p/15645416.html