Description
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 d1d1-th day in the m1m1-th month of year y1y1. Given the day of today on that planet, what day will it be (or was it) on the d2d2-th day in the m2m2-th month of year y2y2 on that planet?
Input
There are multiple test cases. The first line of the input contains an integer TT (about 100), indicating the number of test cases. For each test case:
The first line contains three integers y1y1, m1m1, d1d1 (2000≤y1≤1092000≤y1≤109, 1≤m1≤121≤m1≤12, 1≤d1≤301≤d1≤30) and a string ss, indicating the date and day of today on that planet. It’s guaranteed that ss is either “Monday”, “Tuesday”, “Wednesday”, “Thursday” or “Friday”.
The second line contains three integers y2y2, m2m2 and d2d2 (2000≤y2≤1092000≤y2≤109, 1≤m2≤121≤m2≤12, 1≤d2≤301≤d2≤30), 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 d2d2-th day in the m2m2-th month of year y2y2 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
题目大意
…比较直白
AC代码
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t,a,b,c,a1,b1,c1;
string s,w[5]={"Monday","Tuesday","Wednesday","Thursday","Friday"};
cin>>t;
while(t--)
{
cin>>a>>b>>c>>s>>a1>>b1>>c1;
ll num=(a1-a)*360+(b1-b)*30+c1-c,ans;
num%=5;
if(num<0)
num+=5;
for(int i=0;i<5;++i)
if(s==w[i])
ans=i;
ans=(ans+num)%5;
cout<<w[ans]<<endl;
}
return 0;
}