Task: | Deleting digits |
Sender: | aalto2024e_001 |
Submission time: | 2024-09-30 16:30:38 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.01 s | details |
#10 | ACCEPTED | 0.01 s | details |
#11 | ACCEPTED | 0.01 s | details |
#12 | ACCEPTED | 0.01 s | details |
#13 | ACCEPTED | 0.00 s | details |
Code
#include <algorithm> #include <bits/stdc++.h> #include <string> using namespace std; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define int long long string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(bool b) { return (b ? "true" : "false"); } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif int n; void solve() { cin >> n; int ans = 0; while (n) { string s = to_string(n); int mx = *max_element(all(s)) - '0'; n -= mx; ans++; } cout << ans << '\n'; } signed main() { cin.tie(0)->sync_with_stdio(0); int t = 1; // cin >> t; while (t--) { solve(); } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
4 |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Verdict: ACCEPTED
input |
---|
17 |
correct output |
---|
3 |
user output |
---|
3 |
Test 3
Verdict: ACCEPTED
input |
---|
35 |
correct output |
---|
7 |
user output |
---|
7 |
Test 4
Verdict: ACCEPTED
input |
---|
167 |
correct output |
---|
29 |
user output |
---|
29 |
Test 5
Verdict: ACCEPTED
input |
---|
4434 |
correct output |
---|
687 |
user output |
---|
687 |
Test 6
Verdict: ACCEPTED
input |
---|
9722 |
correct output |
---|
1381 |
user output |
---|
1381 |
Test 7
Verdict: ACCEPTED
input |
---|
37882 |
correct output |
---|
5406 |
user output |
---|
5406 |
Test 8
Verdict: ACCEPTED
input |
---|
103330 |
correct output |
---|
13867 |
user output |
---|
13867 |
Test 9
Verdict: ACCEPTED
input |
---|
562167 |
correct output |
---|
75527 |
user output |
---|
75527 |
Test 10
Verdict: ACCEPTED
input |
---|
991919 |
correct output |
---|
127308 |
user output |
---|
127308 |
Test 11
Verdict: ACCEPTED
input |
---|
999993 |
correct output |
---|
128206 |
user output |
---|
128206 |
Test 12
Verdict: ACCEPTED
input |
---|
999999 |
correct output |
---|
128206 |
user output |
---|
128206 |
Test 13
Verdict: ACCEPTED
input |
---|
23456 |
correct output |
---|
3364 |
user output |
---|
3364 |