Result: Accepted
Time: 6ms
Memory: 1092kB
#include <stdio.h>
int main() {
int y,m,d,w,c;
while(scanf("%d %d %d",&y,&m,&d)!=EOF)
{
c=y/100;
y=y%100;
if(m<3)
{
m=m+12;
y=y-1;
}
w=y+(y/4)+(c/4)-2*c+(26*(m+1)/10)+d-1+700000;
w%=7;
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==0)
{
printf("Sunday\n");
}
}
return 0;
}