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.
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).
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[10]; scanf("%d%d%s",&a,&b,s); int minute=a*60+b-8*60; int add=0,pos; for(pos=4;s[pos]!='