Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <deque>
- #include <algorithm>
- using namespace std;
- int main()
- {
- string input;
- cin >> input;
- if (input[0] == '0')
- putchar('0');
- else
- {
- uint64_t cnt = 0;
- deque<char> first(1);
- int ind = 1;
- first[0] = input[0];
- while (input[ind] == '0')
- first.push_back(input[ind++]);
- deque<char> second(input.size() - ind);
- for (int i = ind; i < input.size(); i++)
- second[i - ind] = input[i];
- auto test = [&first, &second] () {
- if (first.size() == second.size())
- return (lexicographical_compare(first.begin(), first.end(), second.begin(), second.end())
- || equal(first.begin(), first.end(), second.begin(), second.end()));
- else return first.size() <= second.size();
- };
- if (test())
- cnt++;
- while (test())
- {
- first.push_back(second.front());
- second.pop_front();
- while (second.front() == '0')
- {
- first.push_back(second.front());
- second.pop_front();
- }
- if (test())
- cnt++;
- }
- printf("%lld", cnt);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment