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