斐波那契凤尾

题目:https://www.nowcoder.com/pat/2/problem/253

重点是在25位后进行补0

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstdio>
 4 using namespace std;
 5 const int maxn = 100000 + 1;
 6 #define MOD 1000000
 7 int f[maxn];
 8 
 9 void db(){
10     f[1] = 1;
11     f[2] = 2;
12     for (int i = 3; i < maxn; i++){
13         f[i] = f[i - 1] + f[i - 2];
14         f[i] %= MOD;
15     }
16 }
17 
18 int main(){
19     int n;
20     db();
21     while (~scanf("%d",&n)){
22         if (n < 25)
23             printf("%d
", f[n]);
24         else
25         printf("%06d
", f[n]);
26     }
27     //system("pause");
28     return 0;
29 }
原文地址:https://www.cnblogs.com/ouyang_wsgwz/p/8168749.html