fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define double long double
  7. #define endl "\n"
  8. #define NAME "a"
  9.  
  10. const int MAXN = 1e6 + 5;
  11. const int inf = 1e18;
  12. const int MOD = 1e9 + 7;
  13.  
  14. void FileInput(){
  15. if(fopen(NAME".inp" , "r") == NULL)
  16. freopen(NAME".inp" , "w" , stdout);
  17. freopen(NAME".inp" , "r" , stdin);
  18. freopen(NAME".out" , "w" , stdout);
  19. }
  20.  
  21. int n;
  22. int f[MAXN];
  23.  
  24. void solve(){
  25. cin >> n;
  26. f[1] = 1;
  27. f[2] = 2;
  28. f[3] = 4;
  29. for(int i = 4 ; i <= n ; i++){
  30. f[i] = (f[i - 1] + f[i - 2] + f[i - 3]) % MOD;
  31. }
  32.  
  33. cout << f[n] << endl;
  34. }
  35.  
  36. int32_t main(){
  37. //FileInput();
  38. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  39. int t = 1;
  40. // cin >> t;
  41. while(t--)
  42. solve();
  43. return 0;
  44. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
0