Result: Accepted
Time: 5ms
Memory: 1092kB
#include<stdio.h>
int day(int x,int b,int z);
int main()
{
int a,b,c;
while(scanf("%d %d %d",&a,&b,&c)!=EOF){
switch(day(a,b,c)){
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;
case 0:
printf("Sunday\n");
break;
}
}
}
int day(int x,int b,int z){
int c,y,m,d,n;
m=b;
if(m<=2){
m=m+12;
x--;
}
c=x/100;
y=x%100;
d=z;
n=y+y/4+c/4-2*c+26*(m+1)/10+d-1;
n=(n%7+7)%7;//蔡勒公式
return n;
}