Result: Accepted
Time: 7ms
Memory: 1716kB
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
int main()
{
int y,m,d,ans,w;
while(~scanf("%d %d %d",&y,&m,&d)){
if(m==1||m==2){
m+=12,y--;
w=((d+2*m+3*(m+1)/5+y+y/4-y/100+y/400))%7+1;
}else{
w=((d+2*m+3*(m+1)/5+y+y/4-y/100+y/400))%7+1;
}
if(w==1){
printf("Monday\n");
}else if(w==2){
printf("Tuesday\n");
}else if(w==3){
printf("Wednesday\n");
}else if(w==4){
printf("Thursday\n");
}else if(w==5){
printf("Friday\n");
}else if(w==6){
printf("Saturday\n");
}else if(w==7){
printf("Sunday\n");
}
}
}