Submission

Status:

PPTTTTTTTT

Subtask/Task Score:

20/100

Score: 20

User: peilin

Problemset: Strobogrammatic Numbers

Language: cpp

Time: 1.096 second

Submitted On: 2026-09-23 22:08:48

#include<iostream>
#include<string>
using namespace std;

int main() {
	long long low, high;
	cin >> low >> high;
	
	int ans=0;
	for(long long i=low; i<=high; i++) {
		string s=to_string(i);
		string t= "";
		bool ok=true;
	
		for(int j=s.size()-1; j>=0; j--) {
			if(s[j]=='0') t+='0';
			else if(s[j]=='1') t+='1';
			else if(s[j]=='6') t+='9';
			else if(s[j]=='8') t+='8';
			else if(s[j]=='9') t+='6';
			else ok=false;
		}
		if(ok && s==t)
		ans++;
	}
	cout << ans;
	
	return 0;
}