Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: helloskibidi
Problemset: Strobogrammatic Numbers
Language: cpp
Time: 0.036 second
Submitted On: 2026-10-13 23:18:24
#include <bits/stdc++.h>
using namespace std;
int main(){
long long l, r; cin >> l >> r;
pair<char,char> p[5] = {{'0','0'},{'1','1'},{'8','8'},{'6','9'},{'9','6'}};
vector<string> cur[16];
cur[0] = {""};
cur[1] = {"0", "1", "8"};
for(int i=2;i<=15;i++){
for(string j : cur[i-2]){
for(auto k : p){
cur[i].push_back(k.first + j + k.second);
}
}
}
long long cnt = 0;
for(int i=1;i<=15;i++){
for(string s : cur[i]){
if(s[0]=='0') continue;
else{
long long temp = stoll(s);
if(temp>=l && temp<=r) cnt++;
}
}
}
cout << cnt;
}