Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- int f(int n){
- if(!n)
- return 0;
- int m = 0;
- int x = n;
- while(n){
- m = max(m , n % 10);
- n /= 10;
- }
- return 1 + f(x - m);
- }
- signed main()
- {
- int n;
- cin >> n;
- cout << f(n) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement