Korotkodul

1. Утраченный символ

Oct 15th, 2021 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <string>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7. using ll = long long;
  8. int main()
  9. {
  10.     string N;
  11.     cin >> N;
  12.     if (N[0] == '0') {
  13.         cout << 0 << '\n';
  14.         exit(0);
  15.     }
  16.     int sz = N.size();
  17.     ll ans = 0;
  18.     for (int i = 0; i < sz; ++i) {
  19.         //string c = N.substr(0, i + 1);
  20.         //string d = N.substr(i + 1);
  21.         //cout << c << ' ' << d << '\n';
  22.         if (i + 1 < sz - i - 1) {
  23.             if (N[i + 1] != '0') ans++;
  24.         }
  25.         else if (i + 1 == sz - i - 1) {
  26.             string a = N.substr(0, i + 1);
  27.             string b = N.substr(i + 1);
  28.             //cout << a << ' ' << b << '\n';
  29.             if (a <= b) ans++;
  30.         }
  31.         else {
  32.             break;
  33.         }
  34.     }
  35.     cout << ans << '\n';
  36. }
  37.  
Add Comment
Please, Sign In to add comment