Separate the Numbers

  • + 0 comments
    void separateNumbers(string s) {
        int size = s.size();
        for (int i = 1; i <= size / 2; i++) {
            string t = s.substr(0, i);
            string n = t;
            long long count = stoll(t);
            while (t.size() < size) {
                count++;
                t += to_string(count);
            }
            if (t == s) {
                cout << "YES " << n << endl;
                return;
            }
        }
        cout << "NO" << endl;
    }