Description
Input
Output
Sample Input
3 1 11 11111
Sample Output
1 2
8
#include <stdio.h> #include <string.h> #include<ctype.h> #define M 220 int a[M][220]; char str[M]; int main() { int i, j, n, temp, T; scanf("%d",&T); memset(a, 0, sizeof(a)); a[1][0] = 1; a[2][0] = 2; for(i = 3; i < M; i ++) { for(j = 0; j < 220; j ++) a[i][j] = a[i-1][j]+a[i-2][j]; for(j = 0; j < 219; j ++) { if(a[i][j] >= 10000) { temp = a[i][j]/10000; a[i][j] %= 10000; a[i][j+1] += temp; } } } while( T--) { scanf("%s", str); n=strlen(str); i = 219; while(a[n][i] == 0) i--; printf("%d", a[n][i]); i--; while(i >= 0 ) { printf("%04d", a[n][i]); i--; } puts(""); } return 0; }