f(x)为 x+1 这个数去掉后缀0的数,给出n,问经过无数次这种变换后,最多能得到多少个不同的数。
#include <bits/stdc++.h>
using namespace std;
int check(int x)
{
x++;
while(x!=1&&(!(x%10))) x/=10;
return x;
}
int main() {
// your code goes here
int x;cin>>x;
set<int>s;
while(s.find(x)==s.end())
s.insert(x),x=check(x);
cout<<s.size()<<"\n";
return 0;
}