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

题意

已知四个城市之间的时差,已知一个城市的时间,求另一个城市的时间,时间是12进制的,还要分昨天今天明天还有上午下午

题解

转化成24进制的时间又快又不容易出错(之前用12进制WA了N发)

代码

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define scac(x) scanf("%c",&x)
#define sca(x) scanf("%d",&x)
#define sca2(x,y) scanf("%d%d",&x,&y)
#define sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scl(x) scanf("%lld",&x)
#define scl2(x,y) scanf("%lld%lld",&x,&y)
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define scs(x) scanf("%s",x);
#define pri(x) printf("%d\n",x)
#define pri2(x,y) printf("%d %d\n",x,y)
#define pri3(x,y,z) printf("%d %d %d\n",x,y,z)
#define prl(x) printf("%lld\n",x)
#define prl2(x,y) printf("%lld %lld\n",x,y)
#define prl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define prs(x) printf("%s",(x));
#define ll long long
#define LL long long
#define read read()
#define pb push_back
#define mp make_pair
#define P pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(1.0)
#define eps 1e-6
#define inf 1e17
#define INF 0x3f3f3f3f
#define N 205
const int maxn = 1e5+5;
char d[3][100] = {"Yesterday","Today","Tomorrow"};
char city[4] = {'B','W','L','M'};
int ti[4] = {8,-5,0,3};
map<char,int> p;
int t,hh,mm;
char am[2],c1[100],c2[100],day[100];
int kase = 0;
int main()
{
rep(i,0,4)
p[city[i]] = ti[i];
sca(t);
while(t--)
{
scanf("%d:%d",&hh,&mm);
scs(am);
getchar();
scs(c1);
scs(c2);
if(hh==12 && am[0] =='A')
hh = 0;
if(hh<12&&am[0] =='P')
hh+=12;
hh += p[c2[0]] - p[c1[0]]; if(hh < 0)
{
strcpy(day,d[0]);
hh += 24;
}
else if(hh < 24)
{
strcpy(day,d[1]);
}
else
{
strcpy(day,d[2]);
hh-=24;
}
if(hh==0)
{
hh = 12;
am[0] = 'A';
}
else if(hh > 0 && hh < 12)
{
am[0] = 'A';
}
else if(hh==12)
{
am[0] = 'P';
}
else
{
hh -= 12;
am[0] = 'P';
}
printf("Case %d: %s %d:%02d %s\n",++kase,day,hh,mm,am);
}
}

upc组队赛18 THE WORLD【时间模拟】的更多相关文章

  1. upc 组队赛18 STRENGTH【贪心模拟】

    STRENGTH 题目链接 题目描述 Strength gives you the confidence within yourself to overcome any fears, challeng ...

  2. upc组队赛6 Progressive Scramble【模拟】

    Progressive Scramble 题目描述 You are a member of a naive spy agency. For secure communication,members o ...

  3. upc组队赛16 WTMGB【模拟】

    WTMGB 题目链接 题目描述 YellowStar is very happy that the FZU Code Carnival is about to begin except that he ...

  4. upc组队赛15 Lattice's basics in digital electronics【模拟】

    Lattice's basics in digital electronics 题目链接 题目描述 LATTICE is learning Digital Electronic Technology. ...

  5. upc组队赛3 Congestion Charging Zon【模拟】

    Congestion Charging Zon 题目描述 Tehran municipality has set up a new charging method for the Congestion ...

  6. 解决:Win 10 + Mint 18双系统时间不同步,更换系统启动项顺序

    1.win10 & mint 18双系统时间同步: 先打开终端下更新一下时间,确保时间无误: sudo apt-get install ntpdate sudo ntpdate time.wi ...

  7. 10.18 NOIP2018提高组模拟题(二)

    大水题 1.咒语 (curse.pas/c/cpp) [题目描述] 亮亮梦到自己来到了魔法城堡,但一扇巨大的石门阻拦了他通向城堡内的路.正当他沮丧之际,突然发现门上有一处机关,机关上有一张很长的纸条. ...

  8. 18.9.23 PION模拟赛

    U32670 小凯的数字 题目背景 NOIP2018 原创模拟题T1 NOIP DAY1 T1 or DAY 2 T1 难度 是否发现与NOIP2017 DAY1 T1 有异曲同工之妙 说明:#10, ...

  9. upc组队赛3 Chaarshanbegaan at Cafebazaar

    Chaarshanbegaan at Cafebazaar 题目链接 http://icpc.upc.edu.cn/problem.php?cid=1618&pid=1 题目描述 Chaars ...

随机推荐

  1. 【洛谷p1158】导弹拦截

    这道题是个有想法的枚举qwq 导弹拦截[题目链接] 注意:此导弹拦截非彼导弹拦截p1020 导弹拦截 一道题是1999年的,然后我们现在要写的是经过11年韬光养晦之后的导弹拦截 SOLUTION: 要 ...

  2. 大数加减(51nod)

    1005 大数加法 给出2个大整数A,B,计算A+B的结果.     输入 第1行:大数A 第2行:大数B (A,B的长度 <= 10000 需注意:A B有可能为负数) 输出 输出A + B ...

  3. sql 时间函数大全

    1.        当前系统日期.时间    select getdate() 2. dateadd  在向指定日期加上一段时间的基础上,返回新的 datetime 值  例如:向日期加上2天  se ...

  4. Win10系统下插入耳机前面板无声后面板有声的处理

    问题描述: 当耳机插入后面板绿色口(注意:耳机扬声器为绿色口,红色为话筒麦克风:前后面板一样):可以听到声音,但是转到前面板插入后,无声音:调出声音面板发现声音可随音度波动 处理步骤: 1.保证插牢接 ...

  5. echart 折线渐变 加柱形图结合图形,左右纵轴自设置格式,现行图北京渐变 ,x轴字体倾斜

    app.title = '折柱混合'; option = { grid: { left: '5%', //距离左边的距离 right: '5%', //距离右边的距离 top:'8%', bottom ...

  6. Vue+elementui 实现复杂表头和动态增加列的二维表格

    先上完成的效果图:列是根据查询结果增加的 数据格式: 表头的数据取出: data.data.forEach(element => { this.thead.push({ 品名: element. ...

  7. linux系统升级openssh

    一.升级前准备工作 安装openssh过程需gcc,zlib-devel,openssl-devel,等编译环境,如果通过rpm包来安装,需要解决各种依赖包,故配置本地yum源解决依赖问题. 1. 配 ...

  8. [NOI2004]郁闷的出纳员(平衡树)

    [NOI2004]郁闷的出纳员 题目链接 题目描述 OIER公司是一家大型专业化软件公司,有着数以万计的员工.作为一名出纳员,我的任务之一便是统计每位员工的工资.这本来是一份不错的工作,但是令人郁闷的 ...

  9. 牛客ACM赛 B [小a的旅行计划 ]

    链接 B 小a的旅行计划 把\(n\)个数中选任意数分成\(a,b\)两个集合,集合无区别,要求不包含且有交,求方案数.\(n\leq 10^{13}\) 首先讨论\(a,b\)并集是否为全集: 若是 ...

  10. css 响应式(媒介查询)

    1.CSS 来实现响应式 CSS实现响应式网站的布局要用到的就是CSS中的媒体查询接下来来简单介绍一下: @media 类型 and (条件1) and (条件二){css样式} <link r ...