Hdu 大菲波数 简单大数相加
题意:
求出2000以内的斐波那契数
思路:大数相加
Tips:---
Code:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <stdio.h> 2 #include <cstring> 3 4 int f[1010][220]; 5 int main() 6 { 7 int i, j; 8 int n, T; 9 int tmp, ttmp; 10 f[1][0] = f[2][0] = 1; 11 for(i = 3; i < 1010; ++i){ 12 for(j = 0; j <= 210; ++j) 13 f[i][j] = f[i-1][j] + f[i-2][j]; 14 tmp = 0; 15 for(j = 0; j <= 210; ++j){ 16 ttmp = f[i][j] + tmp; 17 tmp = ttmp/10; 18 f[i][j] = ttmp%10; 19 } 20 } 21 22 while(scanf("%d", &T) != EOF) 23 while(T--) 24 { 25 scanf("%d", &n); 26 i = 210; 27 while(f[n][i] == 0) i--; 28 while(i >= 0) 29 printf("%d", f[n][i--]); 30 puts(""); 31 } 32 33 return 0; 34 }