Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: kungarooo
Problemset: Strobogrammatic Numbers
Language: cpp
Time: 0.110 second
Submitted On: 2025-10-01 14:07:50
#include<bits/stdc++.h>
using namespace std;
long long int l,r,cnt=0;
void think(string f,string b){
//cout<<f<<" "<<b<<"\n";
long long int y=stoll(f+b),yy=stoll(f+"0"+b),yyy=stoll(f+"1"+b),yyyy=stoll(f+"8"+b);
if(y>r)return;
if(y>=l&&y<=r)cnt++;
if(yy>=l&&yy<=r)cnt++;
if(yyy>=l&&yyy<=r)cnt++;
if(yyyy>=l&&yyyy<=r)cnt++;
think(f+"0","0"+b);
think(f+"1","1"+b);
think(f+"6","9"+b);
think(f+"8","8"+b);
think(f+"9","6"+b);
}
int main(){
cin>>l>>r;
if(0>=l&&0<=r)cnt++;
if(1>=l&&1<=r)cnt++;
if(8>=l&&8<=r)cnt++;
think("1","1");
think("6","9");
think("8","8");
think("9","6");
cout<<cnt;
return 0;
}