Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 8300 | Accepted: 4002 |
Description
Input
Output
Sample Input
2 8 12 100 200
Sample Output
3 171 2731 845100400152152934331135470251 1071292029505993517027974728227441735014801995855195223534251 规律题:F(n)=F(n-2)*2+F(n-1) ac代码:#include<stdio.h> #include<string.h> #define MAXN 10010 int num[255][MAXN+10]; void db() { memset(num,0,sizeof(num)); num[0][0]=0; num[1][0]=1; num[2][0]=3; int i,j; int c; for(i=3;i<=250;i++) { c=0; for(j=0;j<=MAXN;j++) { num[i][j]=(num[i-2][j]*2+num[i-1][j]+c)%10; c=(num[i-2][j]*2+num[i-1][j]+c)/10; } } } int main() { int i,j,n; db(); while(scanf("%d",&n)!=EOF) { if(n==0) { printf("1\n"); continue; } for(i=MAXN;i>=0;i--) if(num[n][i]) break; for(j=i;j>=0;j--) printf("%d",num[n][j]); printf("\n"); } return 0; }