admin管理员组文章数量:1550649
题目传送门
题目描述
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 <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define io ios::sync_with_stdio(0),cin.tie(0)
#define ms(arr) memset(arr,0,sizeof(arr))
#define mc(a,b) memcpy(a,b,sizeof(b))
#define inf 0x3f3f3f
#define fin freopen("in.txt", "r", stdin)
#define fout freopen("out.txt", "w", stdout)
typedef long long ll;
typedef unsigned long long ULL;
const int mod=1e9+7;
const int N=1e5+7;
int t,s,f;
string m;
string s1,s2;
int main()
{
// fin;
cin>>t;
for(int k=1;k<=t;k++)
{
scanf("%d:%d",&s,&f);
cin>>m>>s1>>s2;
if(m[0]=='A'&&s==12) s=0;
else if(m[0]=='P'&&s!=12) s+=12;
if(s1=="Moscow") s-=3;
else if(s1=="Beijing") s-=8;
else if(s1=="Washington") s+=5;
if(s2=="Moscow") s+=3;
else if(s2=="Beijing") s+=8;
else if(s2=="Washington") s-=5;
printf("Case %d: ",k);
if(s<0){
printf("Yesterday ");
s+=24;
}
else if(s>=24){
printf("Tomorrow ");
s-=24;
}
else printf("Today ");
if(s==0) printf("12:%02d AM\n",f);
else if(s>=1&&s<12) printf("%d:%02d AM\n",s,f);
else if(s==12) printf("12:%02d PM\n",f);
else printf("%d:%02d PM\n",s-12,f);
}
return 0;
}
本文标签: World
版权声明:本文标题:THE WORLD 【模拟】 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1727247985a1104872.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论