Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_DEPRECATE
- #include <iostream>
- #include <vector>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #define ull unsigned long long
- using namespace std;
- ull d[100001][3];
- int main() {
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- d[1][0] = d[1][1] = 1;
- d[1][2] = 0;
- for (int i = 2; i <= n; i++) {
- d[i][0] = (d[i - 1][0] + d[i - 1][1] + d[i - 1][2]) % 12345;
- d[i][1] = d[i - 1][0];
- d[i][2] = d[i - 1][1];
- }
- cout << (d[n][0] + d[n][1] + d[n][2]) % 12345;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment