Salvens

L

Aug 15th, 2023
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <array>
  4. #include <vector>
  5. #include <numeric>
  6. #include <random>
  7. #include <chrono>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11.  
  12. using namespace std;
  13.  
  14. #define int long long
  15.  
  16. const int INF = 1e18 + 7;
  17. const int MAXN = 1e4 + 1000;
  18. const int N = 1e5 + 10;
  19.  
  20. array<int, MAXN> used;
  21.  
  22. void build(int v) {
  23.     int cnt = 0;
  24.     if (v >= 1) {
  25.         if (used[v - 1] == -1) {
  26.             build(v - 1);
  27.         }
  28.         cnt += (used[v - 1] == 0);
  29.     }
  30.     if (v >= 2) {
  31.         if (used[v - 2] == -1) {
  32.             build(v - 2);
  33.         }
  34.         cnt += (used[v - 2] == 0);
  35.     }
  36.     if (v >= 1000) {
  37.         if (used[v - 1000] == -1) {
  38.             build(v - 1000);
  39.         }
  40.         cnt += (used[v - 1000] == 0);
  41.     }
  42.     used[v] = (cnt > 0 ? 1 : 0);
  43. }
  44.  
  45. signed main() {
  46.     ios_base::sync_with_stdio(false);
  47.     cin.tie(nullptr);
  48.  
  49.     int n;
  50.     cin >> n;
  51.     used.fill(-1);
  52.     build(n);
  53. //    for (int i = n; i >= 0; --i) {
  54. //        cout << used[i] << ' ';
  55. //    }
  56. //    cout << '\n';
  57.     cout << (used[n] ? 1 : 2) << '\n';
  58. }
Advertisement
Add Comment
Please, Sign In to add comment