Advertisement
LEGEND2004

E - Three ones

Aug 31st, 2023
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. int n;
  7.  
  8.  
  9. signed main()
  10. {
  11.     cin >> n;
  12.     int f[n + 1];
  13.     f[0] = 1;
  14.     f[1] = 2;
  15.     f[2] = 4;
  16.     for(int i = 3; i <= n; i++){
  17.         f[i] = f[i - 1] + f[i - 2] + f[i - 3];
  18.         f[i] %= 12345;
  19.     }
  20.     cout << f[n] << endl;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement