Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <string>
- #include <algorithm>
- using namespace std;
- map <int, int> m;
- int main(){
- int n;
- cin >> n;
- int cnt = 0;
- for (int i = 0;i < n ; ++i) {
- string d = to_string ( i);
- //cout << d << endl;
- reverse(d.begin (), d.end());
- //cout << d << endl;
- int sum = 0, f = 1;
- for (int i = d.size() - 1 ; i >= 0; -- i){
- sum += (d[i] - '0') * f;
- f *=10;
- //cout << sum << " ";
- }
- // << endl;
- //cout << d << " ";
- //cout << sum << "___" << endl;
- if ((sum + i ) == n) {
- cnt ++;
- }
- }
- cout << cnt << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement