Official

A - Past ABCs Editorial by en_translator


For beginners

This problem can be solved by appropriately converting between strings and numbers.

There operations are required:

  • Let \(T\) be the string consisting of the last three characters of the string given by the input.
  • Convert \(T\) to a number.
  • If \(T\) is between \(1\) and \(349\) (inclusive), and not \(316\), print Yes.
  • Otherwise, print No.

Note that the answer for ABC000 is No.

Sample code (Python)

S = input()
T = S[3:]
T = int(T)
if 1 <= T <= 349 and T != 316:
  print("Yes")
else:
  print("No")

Sample code (C++)

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

int main(){
	string S;
	cin >> S;
	string  TT = S.substr(3);
	int T=stoi(TT);
	if(1 <= T && T <= 349 && T != 316){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

posted:
last update: