Result: Accepted
Time: 7ms
Memory: 1712kB
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
int y, m, d;
while (scanf("%d %d %d", &y, &m, &d) != EOF)
{
if (m == 1 || m == 2)
{
m += 12;
y--;
}
int day = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7;
if (day == 0)
{
printf("Monday\n");
}
else if (day == 1)
{
printf("Tuesday\n");
}
else if (day == 2)
{
printf("Wednesday\n");
}
else if (day == 3)
{
printf("Thursday\n");
}
else if (day == 4)
{
printf("Friday\n");
}
else if (day == 5)
{
printf("Saturday\n");
}
else
{
printf("Sunday\n");
}
}
return 0;
}