Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define IMPOSSIBLE puts("NU"); exit(0);
- using ll = long long;
- constexpr ll ROOT = 2021, BASE = 10;
- void shock(ll &n) {
- if (n < ROOT) {
- IMPOSSIBLE
- }
- ll p = 1;
- while (ROOT * p <= n) {
- p *= BASE;
- }
- n -= (ROOT * p / BASE);
- }
- signed main() {
- ll n;
- cin >> n;
- ll r = 0;
- do {
- r++;
- shock(n);
- } while(n);
- cout << r << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment