Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: zenta4u

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 0.158 second

Submitted On: 2025-10-04 12:00:23

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll low,high,cnt;
void solve(string txt){ // 000000000000000000000000000000000000000000000000000000000000000000000000000000000 
ll x = (txt.length() > 0 ? stoll(txt) : low);
    if(x > high || txt.length() > 16) return;
    
    if(x>=low and txt.front()!='0' and txt.length()>0) {cnt++;}
    solve("1" + txt + "1");
    solve("8" + txt + "8");
    solve("0" + txt + "0");
    solve("6" + txt + "9");
    solve("9" + txt + "6");
}
int main() {
    cin >> low >> high;
    solve("");
    solve("0");
    solve("1");
    solve("8");
    cout<<cnt;

}
/*
0 - 0
1 - 1
6 - 9
8 - 8
9 - 6
solve("0" + txt + "0");
solve("1" + txt + "1");
*/