Submission

Status:

PPTTT-TTTT

Subtask/Task Score:

20/100

Score: 20

User: ThreeDee

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 1.096 second

Submitted On: 2026-10-02 10:05:04

#include <bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0)->sync_with_stdio(0);
	int l,h,sum=0,len,c;
	cin>>l>>h;
	string n;
	for(int j=0;j<=h-l;j++){
		n=to_string(j+l);
		len=n.size();
		c=0;
		for(int i=0;i<(len+1)/2;i++){
			if(n[i]=='1' && n[len-i-1]=='1')c++;
			else if(n[i]=='8' && n[len-i-1]=='8')c++;
			else if(n[i]=='0' && n[len-i-1]=='0')c++;
			else if(n[i]=='6' && n[len-i-1]=='9')c++;
			else if(n[i]=='9' && n[len-i-1]=='6')c++;
		}
		if(c==(len+1)/2)sum++;
	}
	cout<<sum;
}