Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: navysrimuang

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 0.154 second

Submitted On: 2025-10-04 22:06:37

#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
long long low,high,cnt = 0;

void create(string stmp){
  long long val;
  if(!stmp.empty()){
    val = stoll(stmp);
  }else{
    val = low;
  }
  if(val > high || stmp.length() > 16){
    return;
  }else{
    if((val >= low )&& (stmp[0] != '0') && (!stmp.empty())){
      cnt++;
      
    }
    create("0" + stmp + "0");
    create("1" + stmp + "1");
    create("6" + stmp + "9");
    create("8" + stmp + "8");
    create("9" + stmp + "6");
  }

}

int main(){
  cin >> low >> high;
  if(low == 0){
    cnt++;
  }
  create("");
  create("0");
  create("1");
  create("8");

  cout << cnt << endl;
  return 0;
}