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. jmeter测试报告优化

    1.下载jmeter.results.shanhe.me.xsl 将该文件拷贝到jmeter\extras目录下 2.修改jmeter.results.shanhe.me.xsl 这里直接拷贝 jme ...

  2. Json格式化时间

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")@JsonFormat(timezone = "GMT+8", ...

  3. node获取URL数据

    req.method  -->GET req.hostname  -->127.0.0.1 req.originalUrl  -->/test/test/test?name=wang ...

  4. JSON初体验(一):JsonObject解析

    在学校的呆了一段时间,马上又要回去工作了,不说了,我现在介绍一下json相关的内容 1.JSON数据格式(总的来说,json就是一个字符串) 1.整体结构 String json1 = "{ ...

  5. EAS_Table

    SHR人力 员工表 T_BD_PERSON fbirthday 出生日期 femployeetypeid       员工状态   员工状态  T_HR_BDEMPLOYEETYPE        T ...

  6. 10-mongodb启动错误

    1.error信息 python@ubuntu:~$ mongod --22T17:: I CONTROL [initandlisten] MongoDB starting : pid= port= ...

  7. 从浏览器或者Webview 中唤醒APP

    本文来自网易云社区 作者:刘新奇 移动互联时代,很多互联网服务都会同时具备网站以及移动客户端,很多人认为APP的能帮助建立更稳固的用户关系,于是经常会接到各种从浏览器.webview中唤醒APP的需求 ...

  8. VSCode 前端必备插件

    VSCode 前端必备插件 Debugger for Chrome 让 vscode 映射 chrome 的 debug功能,静态页面都可以用 vscode 来打断点调试 { "versio ...

  9. python 网络篇(网络编程)

    一.楔子 你现在已经学会了写python代码,假如你写了两个python文件a.py和b.py,分别去运行,你就会发现,这两个python的文件分别运行的很好.但是如果这两个程序之间想要传递一个数据, ...

  10. CodeForces-1132F Clear the String

    题目链接 https://vjudge.net/problem/CodeForces-1132F 题面 Description You are given a string \(s\) of leng ...