Submission
Status:
----------
Subtask/Task Score:
0/100
Score: 0
User: meme_boi2
Problemset: Strobogrammatic Numbers
Language: cpp
Time: 0.120 second
Submitted On: 2025-09-28 21:29:47
#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 && 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;
}