Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: meme_boi2
Problemset: Strobogrammatic Numbers
Language: cpp
Time: 0.117 second
Submitted On: 2025-09-28 21:34:11
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll l, r,ans;
vector<pair<string,string>> mat ={{"1","1"},{"8","8"},{"6","9"},{"9","6"},{"0","0"}};
void solve(string s){
ll x = (s.length() > 0 ? stoll(s) : l);
if(x > r || s.length() > 15) return;
if(x%10!=0 && s.length() > 0 &&x >= l) {ans++; }
for(int i = 0; i < 5; i++){
solve(mat[i].first + s + mat[i].second);
}
}
int32_t main(){
cin.tie(nullptr)->sync_with_stdio(0);
cin >> l >> r;
solve("");
solve("0");
solve("1");
solve("8");
cout << ans;
}