Time Zone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 495    Accepted Submission(s): 162

Problem Description
Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.
Given a time in Beijing time (UTC +8), Chiaki would like to know the time in another time zone s.
 
Input
There are multiple test cases. The first line of input contains an integer T (1≤T≤106), indicating the number of test cases. For each test case:
The first line contains two integers a, b (0≤a≤23,0≤b≤59) and a string s in the format of "UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y'' (0≤X,X.Y≤14,0≤Y≤9).
 
Output
For each test, output the time in the format of hh:mm (24-hour clock).
 
Sample Input
3
11 11 UTC+8
11 12 UTC+9
11 23 UTC+0
 
Sample Output
11:11
12:12
03:23
 
Source
 
 
题意:北京标准时间是UTC+8
现在给出标准的北京时间和别的地方的时区
要求别的地方的当前时间
模拟题:
注意细节:1 会有浮点误差,所以把小数位拿出来单独计算
     2注意当h小于0的时候,要转换成前一天的时间
     3是UTC-xy时,可以当成是当前时间+16-xy的时间
代码如下
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
int main(){
int T;
scanf("%d",&T);
while(T--){
int hh,mm;
scanf("%d%d",&hh,&mm);
char str[];
scanf("%s",str);
int len=strlen(str);
int flag=;
int th=;
int tm=;
if(str[]=='+'){
for(int i=;i<len;i++){
if(str[i]=='.'){
flag=i;
break;
}
th=th*+str[i]-'';
}
if(flag!=){
tm=str[flag+]-'';
mm+=((tm*)/);
if(mm>=){
mm-=;
th++;
}
}
hh+=(th-);
if(hh>=) hh-=;
if(hh<) hh+=;
if(hh<) cout<<""; //前导零
cout<<hh<<":";
if(mm<) cout<<"";
cout<<mm<<endl;
}else {
int tth=;
int th=;
for(int i=;i<len;i++){
if(str[i]=='.'){
flag=i;
break;
}
tth=tth*+str[i]-'';
}
th-=tth;
if(flag!=){
tm=str[flag+]-'';
mm-=((tm*)/);
if(mm<){
mm+=;
th--;
}
}
hh+=th;
if(hh>=) hh-=;
if(hh<) printf("");
printf("%d:",hh);
if(mm<) printf("");
printf("%d\n",mm);
}
}
return ;
}
/*
01 14 UTC+2.6
19:50
*/

HDU 多校对抗赛 J Time Zone的更多相关文章

  1. HDU 多校对抗赛第二场 1010 Swaps and Inversions

    Swaps and Inversions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  2. HDU 多校对抗赛 D Distinct Values

    Distinct Values Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  3. HDU 多校对抗赛第二场 1004 Game

    Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  4. HDU 多校对抗赛 B Balanced Sequence

    Balanced Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  5. HDU 多校对抗赛 C Triangle Partition

    Triangle Partition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Oth ...

  6. HDU 多校对抗赛 A Maximum Multiple

    Maximum Multiple Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. 2018 HDU多校第四场赛后补题

    2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...

  8. 2018 HDU多校第三场赛后补题

    2018 HDU多校第三场赛后补题 从易到难来写吧,其中题意有些直接摘了Claris的,数据范围是就不标了. 如果需要可以去hdu题库里找.题号是6319 - 6331. L. Visual Cube ...

  9. Contest2073 - 湖南多校对抗赛(2015.04.06)

    Contest2073 - 湖南多校对抗赛(2015.04.06) Problem A: (More) Multiplication Time Limit: 1 Sec  Memory Limit:  ...

随机推荐

  1. 以源码安装的lamp环境为依托,源码安装zabbix监控系统

    1.源码安装lamp环境 1)安装httpd, 以源码httpd-2.4.33为基础,解压后,执行./configure --prefix=/usr/local/ --sysconfdir=/etc/ ...

  2. UVA 1593 Alignment of Code(紫书习题5-1 字符串流)

    You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is ...

  3. HBase Scan,Get用法

    Scan,get用法 1. get help帮助信息 从下列get用法信息可以看出 get 后面可以跟table表名,rowkey,以及column,value.但是如果想通过get直接获取一个表中的 ...

  4. FTP 主动模式与被动模式

    项目中涉及到媒资传输的地方,均有ftp应用,而关于媒资传输故障的排查中,FTP主被动模式问题占了较高比例,但又容易被忽略, 特此收集相关资料介绍,同时整理了如何通wget.tcpdum分辨FTP的主被 ...

  5. Java:详解内部类

    可以将一个类的定义放在另一个类的定义内部,这就是内部类. 内部类是一个非常有用的特性但又比较难理解使用的特性(鄙人到现在都没有怎么使用过内部类,对内部类也只是略知一二). 第一次见面 内部类我们从外面 ...

  6. vs13发布web程序 iis上

    一.配置iis 1,找到控制面板--程序--启用或关闭Windows功能 2,从列表中选择Internet Infomation Services,并且把相应的功能条目勾选上,如果不清楚,可以全部选中 ...

  7. Messy Code in Windows Server 2008 R2 English Edition

          We always use Windows Server 2008 R2 English operation system. And it doesn't have any problem ...

  8. Git 使用 粗糙记录

    版本控制应该是每一个开发人员应该会的东西,奈何,学校没有学习,随着写代码的时间的加长,越来月觉得版本控制的必要性了. 记得在实习的公司,同一痛的都是SVN. 至于GIt和SVN的区别,直接看连接 ht ...

  9. python发起请求提示UnicodeEncodeError

    具体错误: UnicodeEncodeError: 'latin-1' codec can't encode characters in position 73-74: Body ('测试') is ...

  10. i8浏览器不支持placeholder属性解决办法,以及解决后,文字不居中问题

    这里想实现的效果是:设置和移除文本框默认值,如下图鼠标放到文本框中的时候,灰字消失. 1.可以用简单的方式,就是给input文本框加上onfocus属性,如下代码: <input id=&quo ...