Result: Accepted
Time: 6ms
Memory: 1712kB
#include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <list>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
int i, j, k;
int m, n, p;
int main(){
int year, month, day;
while (scanf("%d %d %d", &year, &month, &day) != EOF) {
if (month == 1 || month == 2) {
month += 12;
year--;
}
int week = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400) % 7;
if (week == 0)
printf("Monday\n");
else if (week == 1)
printf("Tuesday\n");
else if (week == 2)
printf("Wednesday\n");
else if (week == 3)
printf("Thursday\n");
else if (week == 4)
printf("Friday\n");
else if (week == 5)
printf("Saturday\n");
else if (week == 6)
printf("Sunday\n");
}
return 0;
}