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