C++)
#include <iostream>
#include <string>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int x, y;
cin >> x >> y;
int month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
string ans[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
int tot = y;
for (int i = 1; i < x; i++)
tot += month[i - 1];
cout << ans[tot % 7];
return 0;
}
Python)
import sys
x, y = map(int, sys.stdin.readline().rstrip().split())
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ans = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
tot = y
for month in range(x-1):
tot += days[month]
print(ans[tot%7])'백준 1 > 구현' 카테고리의 다른 글
| [백준 13458] 시험감독 (C++/Python) (0) | 2020.12.06 |
|---|---|
| [백준 2960] 에라토스테네스의 체 (C++/Python) (0) | 2020.12.06 |
| [백준 2839] 설탕 배달 (C++/Python) (0) | 2020.12.06 |