Start: Jun, 26, 2019 08:30:00
2019年度暑期短学期第一天
End: Jun, 26, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: C
Result: Accepted
Time: 6ms
Memory: 1092kB
Author: 2018212212159
In contest: 1273

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	int w,cent,year,mon,day;
	while(scanf("%d %d %d",&year,&mon,&day)!=EOF)
	{
		if(year>1582||year==1582&&mon>10||year==1582&&mon==10&&day>4)
		{
			cent=year/100;
		    year=year%100;
		   if(mon==1||mon==2)
		  {	
			mon=mon+12;
			year=year-1;
		  }
		
		  w=year+year/4+cent/4-2*cent+13*(mon+1)/5+day-1;
		   w %= 7;
		  if(w<0)
		  {
			w+=7;
		  }
		 
		}
		else
		{
			cent=year/100;
		    year=year%100;
		   if(mon==1||mon==2)
		  {	
			mon=mon+12;
			year=year-1;
		  }
		
		  w=year+year/4+cent/4-2*cent+13*(mon+1)/5+day+2;
		  w %= 7;
		  if(w<0)
		  {
			w+=7;
		  }
		  
		}
		if(w==0)
			printf("Sunday\n");
		else 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");

	}
 	return 0;
}