Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <array>
- #include <vector>
- #include <numeric>
- #include <random>
- #include <chrono>
- #include <set>
- #include <map>
- #include <queue>
- using namespace std;
- #define int long long
- const int INF = 1e18 + 7;
- const int MAXN = 1e4 + 1000;
- const int N = 1e5 + 10;
- array<int, MAXN> used;
- void build(int v) {
- int cnt = 0;
- if (v >= 1) {
- if (used[v - 1] == -1) {
- build(v - 1);
- }
- cnt += (used[v - 1] == 0);
- }
- if (v >= 2) {
- if (used[v - 2] == -1) {
- build(v - 2);
- }
- cnt += (used[v - 2] == 0);
- }
- if (v >= 1000) {
- if (used[v - 1000] == -1) {
- build(v - 1000);
- }
- cnt += (used[v - 1000] == 0);
- }
- used[v] = (cnt > 0 ? 1 : 0);
- }
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- int n;
- cin >> n;
- used.fill(-1);
- build(n);
- // for (int i = n; i >= 0; --i) {
- // cout << used[i] << ' ';
- // }
- // cout << '\n';
- cout << (used[n] ? 1 : 2) << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment