Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- using ll = long long;
- int main()
- {
- string N;
- cin >> N;
- if (N[0] == '0') {
- cout << 0 << '\n';
- exit(0);
- }
- int sz = N.size();
- ll ans = 0;
- for (int i = 0; i < sz; ++i) {
- //string c = N.substr(0, i + 1);
- //string d = N.substr(i + 1);
- //cout << c << ' ' << d << '\n';
- if (i + 1 < sz - i - 1) {
- if (N[i + 1] != '0') ans++;
- }
- else if (i + 1 == sz - i - 1) {
- string a = N.substr(0, i + 1);
- string b = N.substr(i + 1);
- //cout << a << ' ' << b << '\n';
- if (a <= b) ans++;
- }
- else {
- break;
- }
- }
- cout << ans << '\n';
- }
Add Comment
Please, Sign In to add comment