Calandar ZOJ - 4113

博客围绕遥远星球的日期计算展开,该星球一年12个月,每月30天,每周5天。已知某一日期是周几,要求计算另一日期是周几。还提及19年山东省赛相关题目,给出了计算思路,即两日期天数相减加30后对5取余。

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;
}

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值