标签:
Sample Input
2 8 12 100 200
Sample Output
3 171 2731 845100400152152934331135470251 1071292029505993517027974728227441735014801995855195223534251
#include <stdio.h> int main() { int i,j,n,x,a; int s[400][200]={0}; s[0][0]=1; s[1][0]=1; s[2][0]=3; for(i=3;i<350;i++) { for(j=0;j<200;j++) { a=(s[i-2][j]*2+s[i-1][j]+s[i][j]); s[i][j]=a%10; s[i][j+1]=a/10; } } while(scanf("%d",&n)!=EOF) { x=0; for(i=100;i>=0;i--) { if(s[n][i]!=0) {x=i;break;} } for(j=x;j>=0;j--) printf("%d",s[n][j]); printf("\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zhangfengnick/p/4890256.html