Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Bune
Problemset: Strobogrammatic Numbers
Language: cpp
Time: 0.089 second
Submitted On: 2026-08-23 15:54:23
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define ll long long
#define pb push_back
ll l, h;
int cnt = 0;
void rec(string s) {
ll x = 0;
for (char c : s) {
x = x * 10 + (c - '0');
}
if (x > h) {
return;
}
if (s.size() > 15) return;
if (x >= l && x <= h && s[0] != '0') {
cnt++;
}
rec('0'+s+'0');
rec('1'+s+'1');
rec('6'+s+'9');
rec('9'+s+'6');
rec('8'+s+'8');
}
int main() {
fastio
cin >> l >> h;
if (l == 0) {
cnt = 1;
l++;
}
rec("");
rec("0");
rec("1");
rec("8");
cout << cnt << '\n';
return 0;
}