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
19年山东省赛的题,在赛场上,这道题我们什么傻事都做了,回头冷静一看。。。。
每个月30天,每个周5天,已知第一个日期的周几,计算第二个日期周几
30可以被5整除,两个的天相减加个30 再取余5
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string zou[5]={"Friday","Monday","Tuesday","Wednesday","Thursday"};
int main()
{
int t;
cin>>t;
int y1,m1,d1,y2,m2,d2;
string s;
int sum;
while(t--){
sum=0;
cin>>y1>>m1>>d1>>s;
cin>>y2>>m2>>d2;
sum=d2-d1+30;
sum=sum%5;
int p=0;
for(int i=0;i<5;i++){
if(s==zou[i]){
p=i;
}
}
sum+=p;
sum=sum%5;
cout<<zou[sum]<<endl;
}
return 0;
}
博客围绕遥远星球的日期计算展开,该星球一年12个月,每月30天,每周5天。已知某一日期是周几,要求计算另一日期是周几。还提及19年山东省赛相关题目,给出了计算思路,即两日期天数相减加30后对5取余。
898

被折叠的 条评论
为什么被折叠?



