Official
A - Past ABCs Editorial by en_translator
For beginners
- If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest. There you can find a sample code for each language.
- Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.
- 「Python入門 AtCoder Programming Guide for beginners (APG4bPython)」 is a Python tutorial for competitive programmers. Again, this is only in Japanese.
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: