Result: Accepted
Time: 5ms
Memory: 1092kB
#include<stdio.h>
int main(){
int Y,M,D;
int week = -1;
while(scanf("%d %d %d",&Y,&M,&D) != EOF){
if(1 == M || 2 == M)
{
M = M + 12;
Y--;
}
week = (D + 1 + 2*M + 3*(M + 1)/5 + Y + Y / 4 -Y / 100 + Y / 400) % 7;
switch(week){
case 0 : printf("Sunday\n"); break;
case 1 : printf("Monday\n"); break;
case 2 : printf("Tuesday\n"); break;
case 3 : printf("Wednesday\n"); break;
case 4 : printf("Thursday\n"); break;
case 5 : printf("Friday\n"); break;
case 6 : printf("Saturday\n"); break;
default : return NULL; break;
}
}
return 0;
}