On a planet far away from Earth, one year is composed of 12 months, and each month always consists of 30 days.
Also on that planet, there are 5 days in a week, which are Monday, Tuesday, Wednesday, Thursday and Friday. That is to say, if today is Monday, then tomorrow will be Tuesday, the day after tomorrow will be Wednesday. After 3 days it will be Thursday, after 4 days it will be Friday, and after 5 days it will again be Monday.
Today is the -th day in the -th month of year . Given the day of today on that planet, what day will it be (or was it) on the -th day in the -th month of year on that planet?
Input
There are multiple test cases. The first line of the input contains an integer (about 100), indicating the number of test cases. For each test case:
The first line contains three integers , , (, , ) and a string , indicating the date and day of today on that planet. It’s guaranteed that is either “Monday”, “Tuesday”, “Wednesday”, “Thursday” or “Friday”.
The second line contains three integers , and (, , ), indicating the date whose day we want to know.
Output
For each test case output one line containing one string, indicating the day of the -th day in the -th month of year on that planet.
Sample Input
4
2019 5 12 Monday
2019 5 14
2019 5 12 Tuesday
2019 12 30
2019 5 12 Friday
1000000000 1 1
1000000000 1 1 Wednesday
2019 5 12
Sample Output
Wednesday
Friday
Thursday
Thursday
#include<bits/stdc++.h>
using namespace std;
char n[5][10]= {"Monday","Tuesday","Wednesday","Thursday","Friday"};
int main()
{
std::ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--)
{
long long int y,m,d;
char s[10];
cin>>y>>m>>d>>s;
long long int y2,m2,d2;
cin>>y2>>m2>>d2;
long long int sum1=0;
sum1=-(y*360+m*30+d)+(y2*360+m2*30+d2);
int week=sum1%5;
if(week<0)//注意是負數的情況
week+=5;
int j;
for(j=0; j<5; j++)
{
if(strcmp(n[j],s)==0)
break;
}
cout<<n[(j+week)%5]<<endl;
}
return 0;
}