Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- int n, s, cif;
- void solve(int cn)
- {
- s += cn;
- int u = cn % 10;
- cn /= 10;
- u *= (int)pow(10, cif - 1) + 1;
- cn = u + cn;
- if (cn == n)
- return;
- solve(cn);
- }
- int main()
- {
- cin >> n;
- int cn = n;
- do
- {
- cn /= 10;
- cif++;
- } while (cn);
- solve(n);
- cout << s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement