Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: PitsineeN

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 0.151 second

Submitted On: 2026-06-17 14:13:48

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int cnt=0;

void rec(long long int low,long long int high, string temp){
  long long int temp_num = stoll(temp);
  if(temp_num>high || temp.size()>16) return;
  if(temp_num>=low && temp_num>0 && temp[0]!='0') {
    // cout<<temp_num<<' ';
    cnt++;
  }
  
  rec(low, high, "0"+temp+"0");
  rec(low, high, "1"+temp+"1");
  rec(low, high, "8"+temp+"8");
  rec(low, high, "6"+temp+"9");
  rec(low, high, "9"+temp+"6");
    
}

int main(){
  long long int low,high;
  cin>>low>>high;
  /*
  string a="0",b="00";
  cout << "a = " << stoll(a) << "\n";
  cout << "b = " << stoll(b) << "\n";
  */
  rec(low, high, "0");
  rec(low, high, "1");
  rec(low, high, "8");
  rec(low, high, "00");
  rec(low, high, "11");
  rec(low, high, "69");
  rec(low, high, "96");
  rec(low, high, "88");
  
  if(low==0){
    cnt+=1;
  }
  cout<<cnt;
}