Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Imorange

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 0.119 second

Submitted On: 2025-10-13 22:56:30

#include <bits/stdc++.h>

using namespace std;

long long int l ,r;
long long int c= 0;

void sea(string f, string b)
{
  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)c++;
  if(yy>= l && yy <=r)c++;
  if(yyy>= l && yyy <=r)c++;
  if(yyyy>= l && yyyy <=r)c++;
  sea(f+"0", "0"+b);
  sea(f+"1", "1"+b);
  sea(f+'6', '9'+b);
  sea(f+'8', '8'+b);
  sea(f+'9', '6'+b);

}


int main()
{
  cin >> l >> r;
  if(l <= 0 && r >=0)c++;
  if(l<= 1 && r>=1) c++;
  if(l<= 8 && r>=8)c++;
  

  sea("1","1");
  sea("6","9");
  sea("8","8");
  sea("9","6");

  cout << c;
}