版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiang_6/article/details/89738821
直接模拟这个过程,次数不会超过 数的位数*10
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 7;
int n;
set<int> st;
void solve(int n) {
int t = n+1;
while(t%10 == 0) t /= 10;
if(st.count(t)) return;
st.insert(t);
solve(t);
}
int main() {
cin >> n;
st.insert(n);
solve(n);
cout << st.size() << endl;
return 0;
}