A:
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 <iostream>
#include <cstring>
using namespace std;
long long y1,y2;
int m1,m2;
int d1,d2;
char s1[15],s2[15];
int week;
long long sum;
char day[][15] = {"Friday","Monday","Tuesday","Wednesday","Thursday","Friday"} ;
long long zhuanhuan(char *s)
{
if(strcmp(s,"Monday") == 0)
return 1;
if(strcmp(s,"Tuesday") == 0)
return 2;
if(strcmp(s,"Wednesday") == 0)
return 3;
if(strcmp(s,"Thursday") == 0)
return 4;
if(strcmp(s,"Friday") == 0)
return 5;
return 0;
}
int main()
{
int T;
cin>>T;
while(T--)
{
cin >> y1>>m1>>d1>>s1;
cin >> y2>>m2>>d2;
sum = 0;
// 一:
if(y2>y1)
{
sum += (y2-y1-1)*360;
sum += (12-m1+m2)*30;
sum += 30-d1+d2;
sum += zhuanhuan(s1);
cout<<day[sum%5]<<endl;
}
// 二:
else if(y1 == y2)
{
if(m2>m1)
{
sum += (m2-m1-1)*30;
sum += 30-d1+d2;
sum += zhuanhuan(s1);
cout<<day[sum%5]<<endl;
}
else if(m1 == m2)
{
if(d2>=d1)
{
sum += d2-d1;
sum += zhuanhuan(s1);
cout<<day[sum%5]<<endl;
}
else
{
sum += d1-d2;
cout<<day[ (zhuanhuan(s1)+5 -(sum%5)) %5]<<endl;
}
}
else
{
sum += (m1-m2-1)*30;
sum += 30-d2+d1;
cout<<day[ (zhuanhuan(s1)+5 -(sum%5)) %5]<<endl;
}
}
// 三:
else
{
sum += (y1-y2-1)*360;
sum += (12-m2+m1)*30;
sum += 30-d2+d1;
cout<<day[ (zhuanhuan(s1)+5 -(sum%5)) %5]<<endl;
}
}
return 0;
}
本文探讨了一个远离地球的虚构星球上的独特历法系统,该星球的一年由12个月组成,每个月30天,一周包含5天,即周一至周五。通过编程算法,实现对这个星球上特定日期到另一日期间星期几的转换和计算,适用于多种测试案例。
1428

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



