zoukankan      html  css  js  c++  java
  • 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 d_1d1-th day in the m_1m1-th month of year y_1y1. Given the day of today on that planet, what day will it be (or was it) on the d_2d2-th day in the m_2m2-th month of year y_2y2 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 y_1y1m_1m1d_1d1 (2000 le y_1 le 10^92000y1109, 1 le m_1 le 121m112, 1 le d_1 le 301d130) 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 y_2y2m_2m2 and d_2d2 (2000 le y_2 le 10^92000y2109, 1 le m_2 le 121m212, 1 le d_2 le 301d230), 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 d_2d2-th day in the m_2m2-th month of year y_2y2 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

    代码     ps:只需要看day,与year和month无关

     1 #include<iostream>
     2 using namespace std;
     3 int main(){
     4     int t;
     5     int y,m,d;
     6     int y1,m1,d1;
     7     char s[10];
     8     scanf("%d",&t);
     9     while(t--){
    10         scanf("%d %d %d %s",&y,&m,&y,s);
    11         scanf("%d %d %d",&y1,&m1,&y1);
    12         int n=(y1-y)%5;
    13         int k;
    14         if(s[0]=='M') k=0;
    15         else if(s[0]=='T'&&s[1]=='u') k=1;
    16         else if(s[0]=='W') k=2;
    17         else if(s[0]=='T'&&s[1]=='h') k=3;
    18         else if(s[0]=='F') k=4;
    19         if(n<=0) k=(k+5+n)%5;
    20         else k=(k+n)%5;
    21         if(k==0) printf("Monday
    ");
    22         else if(k==1) printf("Tuesday
    ");
    23         else if(k==2) printf("Wednesday
    ");
    24         else if(k==3) printf("Thursday
    ");
    25         else if(k==4) printf("Friday
    ");
    26     }
    27 }
  • 相关阅读:
    Nbear讲解 之核心类CodeGenerator
    计算字符串显示的像素
    C# 加密算法[汇总]
    索引器的本质
    Excel[.xls|.xlsx|.csv] 导入 导出
    Spring.Net Ioc 实例
    反射中 BindingFlags标识
    C# 图片操作 常用方法 总结
    iTextSharp 生成pdf Form 实例
    玩转 Route
  • 原文地址:https://www.cnblogs.com/-happy-/p/12517839.html
Copyright © 2011-2022 走看看