UPC Contest 1747 THE WORLD

阅读: 评论:0

UPC Contest 1747 THE WORLD

UPC Contest 1747 THE WORLD

题目描述

The World can indicate world travel, particularly on a large scale. You mau 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 globalawareness, and you will have a new appliciation 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 t he local time of a city, you are expected to calculate the date and local time of another specific city among the above capitals.

 

输入

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.

 

输出

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.

 

样例输入

复制样例数据

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

样例输出

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

AC代码

#include<bits/stdc++.h>
using namespace std;
string t2;
map<string,int>q;
int main()
{q["Beijing"]=8;q["Washington"]=-5;q["London"]=0;q["Moscow"]=3;int t;cin>>t;for(int i=1;i<=t;i++){int h=0,m=0;scanf("%d:%d",&h,&m);cin>>t2;string s1,s2;cin>>s1>>s2;if(t2=="PM"&&h!=12){h+=12;}if(t2=="AM"&&h==12)h=0;h-=q[s1];h+=q[s2];cout<<"Case "<<i<<": ";if(h<0)h+=24,cout<<"Yesterday ";else if(h>=24)h-=24,cout<<"Tomorrow ";elsecout<<"Today ";if(h==0)printf("12:%02d AMn",m);else if(h>=1&&h<12)printf("%d:%02d AMn",h,m);else if(h==12)printf("12:%02d PMn",m);elseprintf("%d:%02d PMn",h-12,m);}
}

 

本文发布于:2024-02-01 10:05:39,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170675314135874.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:Contest   UPC   WORLD
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23