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. ruby OpenURI模块使用

    OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP(OpenURI支持重定向) 像打开普通文件那样打开ht ...

  2. node解析post表单信息

    一共有4种解析方式 urlencoded.json.text .raw 发起请求的form表单中可以设置三种数据编码方式 application/x-www-form-urlencoded.multi ...

  3. R语言学习笔记(三):零碎知识点(1-10)

    1--c() c表示"连接"(concatenate). 在R中向量是连续存储的,因此不能插入或删除元素. 2--seq() seq()的特殊用法,可以用在for循环里for(i ...

  4. 20145202马超 2016-2017-2 《Java程序设计》第一次实验

    之前做的(http://www.cnblogs.com/tuolemi/p/5707098.html) 其余的 断点的使用 行断点 条件断点 参考(http://www.cnblogs.com/roc ...

  5. mysql 函数以及操作总结

    1. 拼接 concat(参数1,参数2,.. ,参数)  实现将多个字符串拼接到一起 要批量修改一个字段值   字段值又是复杂的sql 计算得来   通过查询字段值 和 修改的条件fundId(这是 ...

  6. 创龙TMS320C6748开发板串口和中断学习笔记

    1. 硬件上,底板有2个串口,UART1和UART2(使用了MAX3232电平转换芯片),其中UART2也可以转RS485的. 2. 看下数据手册部分,不过一直不理解过采样的意思,16字节的FIFO ...

  7. ExtJs工具篇(3)——Aptana Studio3乱码的问题

            在Aptana Studio里面使用,发现输入的中文是乱码,在浏览器中浏览也是乱码,想着肯定是编码的问题,但是一直没有找到在那个地方设置.以为汉化后就可以了,没想到汉化后竟然还是乱码, ...

  8. 【Spring实战】----开篇(包含系列目录链接)

    [Spring实战]----开篇(包含系列目录链接) 置顶2016年11月10日 11:12:56 阅读数:3617 终于还是要对Spring进行解剖,接下来Spring实战篇系列会以应用了Sprin ...

  9. Flexbox布局模式的理解

    个人博客地址:  雨中的鱼-前端知识分享   http://www.showhtml5.cc    分享干货,有兴趣的人可以一起来分享前端知识  加Q群:440279380   Flexbox,一种C ...

  10. jmeter插件之jsonpath提取响应结果和做断言

    准备工作: 1. jmeter3.X已经自带了提取响应结果的插件:JSON Extractor 2. 下载断言插件:https://jmeter-plugins.org/wiki/JSONPathAs ...