Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- vector <bool> prost(10000, 1);
- vector <bool> used(10001, 0);
- vector <bool> w(10001, 0);
- void pr (int n) {
- prost[0] = prost[1] = 0;
- for (int i = 2; i < 10000; ++i) {
- if (prost[i]) {
- for (int j = i * i; j < 10000; j += i) {
- prost[j] = 0;
- }
- }
- }
- }
- bool a (int n) {
- if (!n)
- return 0;
- if (used[n])
- return w[n];
- used[n] = 1;
- bool q = 0, g;
- for (int i = 1; i < 4; ++i) {
- if (n < i || prost[n - i]) continue;
- g = a(n - i);
- if (!g)
- q = 1;
- }
- w[n] = q;
- return q;
- }
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- #endif // ONLINE_JUDGE
- int n;
- cin >> n;
- pr(n);
- if (a(n))
- cout << 1;
- else cout << 2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement