UVa12019

題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=242&page=show_problem&problem=3170

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

using namespace std;

int main(){
// 因為doomsday很難算 用1/1是禮拜六去推比較快
int daysOfMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int cases;
cin >> cases;
while(cases--){
int m, d;
cin >> m >> d;
int current_m=1, current_d=1, day = 6;
while(current_m != m){
day += daysOfMonth[current_m];
++current_m;
}
while(current_d != d){
++day;
++current_d;
}
day %= 7;
cout << days[day] << '\n';
}
return 0;
}