Submission

Status:

PPTTTTTTTT

Subtask/Task Score:

20/100

Score: 20

User: Bune

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 1.095 second

Submitted On: 2026-08-23 15:14:20

#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define ll long long
#define pb push_back

int main() {
  fastio

  ll l, h;
  cin >> l >> h;

  int cnt = 0;

  for (ll i = l; i <= h; i++) {
    string s = to_string(i);

    bool isValid = true;

    for (ll j = 0; j <= s.length() / 2; j++) {
      if (!((s[j] == '1' && s[s.length() - 1 - j] == '1') || (s[j] == '0' && s[s.length() - 1 - j] == '0') || (s[j] == '8' && s[s.length() - 1 - j] == '8') || (s[j] == '6' && s[s.length() - 1 - j] == '9') || (s[j] == '9' && s[s.length() - 1 - j] == '6'))) {
        isValid = false;
      }
    }

    if (isValid) {
      cnt++;
    }
  }

  cout << cnt << '\n';

  return 0;
}