Submission

Status:

PPTTT-TTTT

Subtask/Task Score:

20/100

Score: 20

User: Win007

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 1.097 second

Submitted On: 2025-10-06 09:27:38

#include <bits/stdc++.h>
using namespace std;
bool stroCheck(string s){
    int x=s.length()-1;
    for(int i=0; i<=x/2; i++){
            if(s[i]=='6'){
                s[i]='9';
            }else if(s[i]=='9'){
                s[i]='6';
            }
            if((s[i]!=s[x-i])||((s[i]!='0')&&(s[i]!='1')&&(s[i]!='8')&&(s[i]!='6')&&(s[i]!='9'))){
                return 0;
            }
    }
    return 1;
}
int main(){
    int a,b,n=0;
    cin>>a>>b;
    for(int i=a; i<=b; i++){
        if(stroCheck(to_string(i))==1){
            n++;
            //cout<<i<<" ";
        }
    }
    //cout<<endl;
    cout<<n;
}