f709. 12019 - Doom's Day Algorithm
Tags : CPE UVA
Accepted rate : 528人/546人 ( 97% ) [非即時]
評分方式:
Tolerant

最近更新 : 2021-03-25 18:27

Content

給日期,問那天星期幾

Doom’s day algorithm is not a method to compute which day the world will end. It is an algorithm created by the mathematician John Horton Conway, to calculate which day of the week (Monday, Tuesday, etc.) corresponds to a certain date.
This algorithm is based in the idea of the doomsday, a certain day of the week which always occurs in the same dates. For example, 4/4 (the 4th of April), 6/6 (the 6th of June), 8/8 (the 8th of August), 10/10 (the 10th of October) and 12/12 (the 12th of December) are dates which always occur in doomsday. All years have their own doomsday.
In year 2011, doomsday is Monday. So all of 4/4, 6/6, 8/8, 10/10 and 12/12 are Mondays. Using that information, you can easily compute any other date. For example, the 13th of December 2011 will be Tuesday, the 14th of December 2011 will be Wednesday, etc.
Other days which occur on doomsday are 5/9, 9/5, 7/11 and 11/7. Also, in leap years, we have the following doomsdays: 1/11 (the 11th of January) and 2/22 (the 22nd of Febrary), and in non-leap years 1/10 and 2/21.
Given a date of year 2011, you have to compute which day of the week it occurs.

Input

第一行有個T代表詢問的日期數(T<=100)
接下來會有T行,每行都有一組M、D分別代表月份和日期

The input can contain different test cases. The first line of the input indicates the number of test cases.
For each test case, there is a line with two numbers: M D. M represents the month (from 1 to 12) and D represents the day (from 1 to 31). The date will always be valid.

Output

輸出那天星期幾

For each test case, you have to output the day of the week where that date occurs in 2011. The days of the week will be: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

Sample Input #1
9
1 6
2 28
4 5
5 26
8 1
11 1
12 25
12 31
3 9
Sample Output #1
Thursday
Monday
Tuesday
Thursday
Monday
Tuesday
Sunday
Saturday
Wednesday
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (33%): 1.0s , <1K
公開 測資點#1 (33%): 1.0s , <1K
公開 測資點#2 (34%): 1.0s , <1K
Hint :

2021 3月CPE第一題

Tags:
CPE UVA
出處:
UVA12019 [管理者: DE45A(一葉之秋) ]


ID User Problem Subject Hit Post Date
34421 s9788888@gma...(百鬼大好き) f709
103 2023-03-17 18:11
33866 raphaelchu02...(Raphael) f709
坑人
127 2023-02-09 23:28
32408 joha91100800...(葉峻翰) f709 258 2022-10-08 03:54
26411 wubaie(小億) f709
1265 2021-08-05 13:35
26067 andy8787codi...(coding宏宏) f709
python小提示
711 2021-07-15 01:31