Official
A - Gothec 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.
Implementation approach
Manage the five dates of the festivals in a list, and inspect each element to check if it coincides with \((M,D)\).
Sample code in (Python 3, C++)
The following is sample code in Python 3.
m, d = map(int, input().split())
gossekulist = [(1,7), (3,3), (5,5), (7,7), (9,9)]
if ((m,d) in gossekulist):
print("Yes")
else:
print("No")
The following is sample code in C++.
#include <iostream>
using std::cin;
using std::cout;
#include <vector>
using std::vector;
using std::pair;
using std::make_pair;
int main (void) {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
int m, d;
cin >> m >> d;
vector<pair<int, int> > gosekkulist = {
{1,7},
{3,3},
{5,5},
{7,7},
{9,9}
};
bool isgosekku = false;
for (const pair<int,int> &date : gosekkulist) {
if (make_pair(m,d) == date) isgosekku = true;
}
if (isgosekku) {
cout << "Yes" << "\n";
} else {
cout << "No" << "\n";
}
return 0;
}
posted:
last update: