72552024-01-05 15:38:05anonSzámjegy keveréscpp17Runtime error 22/406ms4808 KiB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
using namespace std;
int main() {
    FastIO;
    ll zc, ans;
    string N;
    cin >> N;
    ans = 0;
    while(N != "0") {
        sort(all(N));
        zc = find_if(all(N), [](auto a) { return a != '0'; }) - N.begin();
        N = N.substr(zc, 1) + string(zc, '0') + N.substr(zc + 1);
        N = to_string(stoll(N) - 1);
        ans++;
    }
    cout << ans << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/03ms1832 KiB
2Accepted0/03ms2024 KiB
3Runtime error0/04ms2992 KiB
4Accepted2/23ms2484 KiB
5Accepted2/22ms2564 KiB
6Accepted2/23ms2568 KiB
7Accepted2/23ms2936 KiB
8Accepted2/23ms2864 KiB
9Accepted2/23ms3264 KiB
10Accepted2/23ms3136 KiB
11Accepted4/43ms3280 KiB
12Accepted4/43ms3168 KiB
13Runtime error0/26ms3812 KiB
14Runtime error0/24ms3784 KiB
15Runtime error0/26ms4320 KiB
16Runtime error0/26ms4528 KiB
17Runtime error0/26ms4760 KiB
18Runtime error0/26ms4648 KiB
19Runtime error0/36ms4800 KiB
20Runtime error0/36ms4808 KiB