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