anon20016

B

Nov 18th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #define _CRT_SECURE_NO_DEPRECATE
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. #include <string>
  6. #include <map>
  7. #include <set>
  8. #include <algorithm>
  9.  
  10. #define ull unsigned long long
  11.  
  12. using namespace std;
  13.  
  14. ull d[100001][3];
  15.  
  16. int main() {
  17. //freopen("input.txt", "r", stdin);
  18. //freopen("output.txt", "w", stdout);
  19. int n;
  20. cin >> n;
  21. d[1][0] = d[1][1] = 1;
  22. d[1][2] = 0;
  23. for (int i = 2; i <= n; i++) {
  24. d[i][0] = (d[i - 1][0] + d[i - 1][1] + d[i - 1][2]) % 12345;
  25. d[i][1] = d[i - 1][0];
  26. d[i][2] = d[i - 1][1];
  27. }
  28. cout << (d[n][0] + d[n][1] + d[n][2]) % 12345;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment