Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: devilpoohs

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 0.060 second

Submitted On: 2026-03-09 14:20:40

#include<bits/stdc++.h>
using namespace std;
#define int long long
int l,h;
int cnt=0;

bool chk(int num){
    return num>=l and num<=h;
}

void think(string a,string b){
    string temp=a+b;
    if(stoll(temp)>h or stoll(temp)==0) return ;
    if(stoll(temp)>=l and stoll(temp)<=h){
        cnt++;
        // cout<<temp<<' ';
        // return ;
    }
    temp=a+"0"+b;
    if(stoll(temp)>=l and stoll(temp)<=h){
        cnt++;
        // cout<<temp<<' ';
        // return ;
    }
    temp=a+"1"+b;
    if(stoll(temp)>=l and stoll(temp)<=h){
        cnt++;
        // cout<<temp<<' ';
        // return ;
    }
    temp=a+"8"+b;
    if(stoll(temp)>=l and stoll(temp)<=h){
        cnt++;
        // cout<<temp<<' ';
        // return ;
    }
    think(a+"9","6"+b);
    think(a+"6","9"+b);
    think(a+"1","1"+b);
    think(a+"0","0"+b);
    think(a+"8","8"+b);
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>l>>h;
    if(chk(0)) cnt++;
    if(chk(8)) cnt++;
    if(chk(1)) cnt++;
    think("1","1");
    think("6","9");
    think("9","6");
    think("8","8");
    cout<<cnt;
    return 0;
}