STANAANDREY

socant (12)

Dec 28th, 2021 (edited)
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define IMPOSSIBLE puts("NU"); exit(0);
  4. using ll = long long;
  5. constexpr ll ROOT = 2021, BASE = 10;
  6.  
  7. void shock(ll &n) {
  8.     if (n < ROOT) {
  9.         IMPOSSIBLE
  10.     }
  11.  
  12.     ll p = 1;
  13.     while (ROOT * p <= n) {
  14.         p *= BASE;
  15.     }
  16.     n -= (ROOT * p / BASE);
  17. }
  18.  
  19. signed main() {
  20.     ll n;
  21.     cin >> n;
  22.  
  23.     ll r = 0;
  24.     do {
  25.         r++;
  26.         shock(n);
  27.     } while(n);
  28.     cout << r << endl;
  29.     return 0;
  30. }
  31.  
Add Comment
Please, Sign In to add comment