Result: Accepted
Time: 5ms
Memory: 1716kB
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int y,m,d,t,i,x;
int a[15]={0,31,28,31,30,31,30,31,31,30,31,30,31},s[15]={0};
int main(){
for(i=1;i<=12;i++) s[i]=a[i]+s[i-1];
while(scanf("%d %d %d",&y,&m,&d)!=EOF){
x=0,t=0;
for(i=1;i<y;i++){
if((i%4==0&&i%100!=0)||i%400==0) x++;
}
t+=(y-1)*365+x;
t+=s[m-1]+d;
if(((y%4==0&&y%100!=0)||y%400==0)&&m>=3) t++;
t=t%7;
if(t==1) printf("Monday\n");
else if(t==2) printf("Tuesday\n");
else if(t==3) printf("Wednesday\n");
else if(t==4) printf("Thursday\n");
else if(t==5) printf("Friday\n");
else if(t==6) printf("Saturday\n");
else if(t==0) printf("Sunday\n");
}
}