Time Zone

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

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
 
 
题目大意:
给你UTC+8的时间,求给定时区的时间。
 
模拟题。
是水题没错的,但是不仔细做还是会wa得很惨QAQ...
1、这里的时区并不是标准的时区定义,所以直接根据差值加减就好啦。
2、转化成分钟加加减减或许是最好的方法。
3、X可能是两位数。
我是先把给的时间转移到UTC+0(UTC-0),这样处理起来感觉更方便。
 
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath> using namespace std; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b;
char s[];
scanf("%d%d%s",&a,&b,s);
int minute=a*+b-*; int add=,pos;
for(pos=;s[pos]!='\0';pos++)
{
if(s[pos]=='.')break;
add=add*+s[pos]-'';
}
if(s[pos]=='.')add=add*+(s[pos+]-'')*;
else add=add*; if(s[]=='+')
minute+=add;
else
minute-=add;
if(minute>=*)
minute=minute-*;
if(minute<)
minute=minute+*; printf("%02d:%02d\n",minute/,minute%);
}
return ;
}

最新文章

  1. 导出csv文件示例
  2. FIFA halts 2026 bids amid scandal 国际足联在丑闻期间停止2026年足球世界杯申请
  3. LightOJ1017 Brush (III)(DP)
  4. PCL点云库:Kd树
  5. Java web项目引用java项目,类型找不到
  6. Collaborative&#160;filtering
  7. ios开发之AppDelegate
  8. jsp 多条记录提交
  9. iOS UIView指定显示摸一个角弧形显示
  10. POJ2069 最小球体覆盖, 模拟退火
  11. spring cloud 入门系列五:使用Feign 实现声明式服务调用
  12. Springmvc中@RequestMapping 属性用法归纳
  13. HTML load事件和DOMCOntentLoaded事件
  14. android adb命令 抓取系统各种 log
  15. SQL-28 查找描述信息中包括robot的电影对应的分类名称以及电影数目,而且还需要该分类对应电影数量&gt;=5部
  16. ngxinx 配置
  17. Solving the SQL Server Multiple Cascade Path Issue with a Trigger (转载)
  18. LeetCode--191--位1的个数
  19. 【专题】计数问题(排列组合,容斥原理,Prufer序列)
  20. ef——存储过程

热门文章

  1. Composer依赖管理 – PHP的利器
  2. Linux\Nginx 虚拟域名配置及测试验证
  3. 【Luogu P3384】树链剖分模板
  4. The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml or the jar files deployed with this application] with root cause异常处理及解释
  5. Docker从门外到入门使用
  6. Head First设计模式——模板方法模式
  7. Wordpress未授权查看私密内容漏洞 分析(CVE-2019-17671)
  8. 20190908write from memory
  9. 华为云ModelArts2.0来袭
  10. 一条数据的HBase之旅,简明HBase入门教程4:集群角色