G.cpp 466 B

123456789101112131415161718192021
  1. //
  2. // Created by liuhuan on 18-11-7.
  3. //
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6. const int MOD = 100000007;
  7. int main() {
  8. int F[100002][2] = {0};
  9. F[1][0] = 1, F[1][1] = 1;/*将n=1单独写*/
  10. F[2][0] = 2;/*进行递推*/
  11. F[2][1] = 1;
  12. int n;
  13. cin >> n;
  14. for (int i = 3; i <= n; i++) {
  15. F[i][0] = (F[i - 1][0] + F[i - 1][1]) % MOD;
  16. F[i][1] = F[i - 1][0];
  17. }
  18. cout << (F[n][0] + F[n][1]) % MOD << endl;
  19. return 0;
  20. }