Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;typedef long double llf;typedef double fl;typedef string str;typedef pair<double, double> dd;
- typedef vector<int> vi;typedef vector<vector<int>> vvi;typedef vector<fl> vf;typedef vector<ll> vl;
- typedef vector<llf> vlf;typedef vector<char> vc;typedef vector<str> vs;typedef pair<int,int> ii;
- # define f(i,a,b,c) for(ll i=a;i<b;i+=c)
- # define fd(i,a,b,c) for(ll i=a;i>=b;i-=c)
- # define w(x) while(x--)
- # define ctoi(a) (a-'0')
- # define pb push_back
- # define eb emplace_back
- # define lb lower_bound
- # define ub upper_bound
- # define be(x) x.begin(), x.end()
- # define rbe(x) x.rbegin(), x.rend()
- # define _(x) ios::sync_with_stdio(0);cin.tie(0);cout.precision(x);cout.setf(ios::fixed);
- int n, re=0;
- int ma(int x){
- int mai, num;
- str p = to_string(x);
- mai=0;
- for(char i:p)num = ctoi(i), mai = max(mai, num);
- return mai;
- }
- int dp(int x){
- if(x==0)return re;
- ++re;
- return dp(x - ma(x));
- }
- int main(){_(0)
- cin>>n;
- cout<<dp(n)<<'\n';
- return 0;}
Add Comment
Please, Sign In to add comment