Submission

Status:

PP---P----

Subtask/Task Score:

30/100

Score: 30

User: letdown

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 0.028 second

Submitted On: 2025-10-12 18:34:50

#include <iostream>
#include <vector>

using namespace std;
vector<string> createStrobo(int len) {
    vector<string> strobo = {"0", "1", "8", "69", "96", "88"};
    int i = 0;
    while(1) {
        string mid = strobo[i];
        if (mid.length() >= len-1) break;
        if (mid.length() < len-2) strobo.push_back("0" + mid + "0");
        strobo.push_back("1" + mid + "1");
        strobo.push_back("6" + mid + "9");
        strobo.push_back("8" + mid + "8");
        strobo.push_back("9" + mid + "6");
        i++;
    }
    return strobo;
}

int main() {
    long long low, high, ans=0;
    cin >> low >> high;

    int l = to_string(high).length();
    vector<string> strobo = createStrobo(l);
    for (auto s : strobo) {
        // cout << s << " ";
        if (s == "" || s[0] == '0') continue;
        long long sint = stoll(s);
        if (sint >= low && sint <= high) ans++;
    }
    cout << ans;
    // vector<string> strobo = createStrobo(6);
    // for (auto s : strobo) cout << s << " ";
}