hdu6556__The World

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 215    Accepted Submission(s): 99


 

Problem Description

The World can indicate world travel, particularly on a large scale. You may be lucky enough to be embarking on a six-month overseas trip, or are working, studying or living overseas for an extended period of time. Similarly, this card reinforces Universal understanding and global awareness, and you will have a new appreciation for people and cultures from across the world.

Across the world there are various time zones, leading to time differences. Here you are informed of several famous capitals and their corresponding time zones.

  • Beijing - China - UTC + 8 (China Standard Time)
  • Washington - United States - UTC - 5 (Eastern Standard Time)
  • London - United Kingdom - UTC (Greenwich Mean Time)
  • Moscow - Russia - UTC + 3 (Moscow Time)
  • Given the local time of a city, you are expected to calculate the date and local time of another specific city among the above capitals.

 

 

Input

The first line of input contains a single integer T ≤ 1000 indicating the number of testcases.
Each testcase consists of three lines. The first line is in the form of “hour:minute AM/PM” (1 ≤ hour ≤ 12, 00 ≤ minute ≤ 59) indicating the local time. Next two lines contain two strings s1, s2. s1 is the name of city corresponding to the given time, while s2 indicates the city you are expected to calculate the local time.

 

 

Output

For each testcase, begin with “Case i:”, where i indicate the case number, and then output a single line in the following format“Yesterday/Today/Tomorrow hour:minute AM/PM”, separated by spaces. The first word describes the corresponding date.

 

 

Sample Input


 

2 12:00 AM London Moscow 4:00 PM London Beijing

 

 

Sample Output


 

Case 1: Today 3:00 AM Case 2: Tomorrow 12:00 AM

 

 

Source

2018CCPC吉林賽區(重現賽)- 感謝北華大學

 

 

Recommend

chendu   |   We have carefully selected several similar problems for you:  6566 6565 6564 6563 6562 

ps:注意差值13市區的判斷就行了

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

char s[10][100];
int a[30];

int main(){
    int t;scanf("%d",&t);
    int cas=0;
    a['L'-'A']=0;
    a['M'-'A']=3;
    a['W'-'A']=-5;
    a['B'-'A']=8;
    while(t--){
        for(int i=0;i<4;i++){
            scanf("%s",s[i]);
        }
        printf("Case %d: ",++cas);
        int hour=0,minu=0;
        int flag=1;
        for(int j=0;s[0][j];j++){
            if(s[0][j]==':'){flag=0;continue;}
            if(flag){
                hour=hour*10+s[0][j]-'0';
            }
            else {
                minu=minu*10+s[0][j]-'0';
            }
        }
        int x=a[s[3][0]-'A']-a[s[2][0]-'A'];
        int tmp=hour;
        if(tmp==12)tmp=0;
        hour=(hour+x+12)%12;
        if(hour==0)hour=12;
        if(x==0){
            printf("Today %s %s\n",s[0],s[1]);
        }
        else if(x>0){
            if(tmp+x<12){
                printf("Today %d:%02d %s\n",hour,minu,s[1]);
            }
            else{
                if(s[1][0]=='A'){
                    if(tmp+x<24)printf("Today %d:%02d PM\n",hour,minu);
                    else printf("Tomorrow %d:%02d AM\n",hour,minu);
                }
                else{
                    if(tmp+x==24)printf("Tomorrow %d:%02d PM\n",hour,minu);
                    else printf("Tomorrow %d:%02d AM\n",hour,minu);
                }
            }
        }
        else{
            if(tmp+x>=0){
                printf("Today %d:%02d %s\n",hour,minu,s[1]);
            }
            else{
                if(s[1][0]=='A'){
                    if(tmp+x>=-12)printf("Yesterday %d:%02d PM\n",hour,minu);
                    else printf("Yesterday %d:%02d AM\n",hour,minu);
                }
                else{
                    if(tmp+12+x>=0)printf("Today %d:%02d AM\n",hour,minu);
                    else{
                        printf("Yesterday %d:%02d PM\n",hour,minu);
                    }
                }
            }
        }
    }
    return 0;
}





 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章