HDU6308 TIme zone

Time Zone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2632 Accepted Submission(s): 831

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≤
10
6
), 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

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>
using namespace std;
const int mod = 24*60;
float s;
char c;
int h,m;
int main()
{
    int T;
    scanf("%d",&T);
    while(T--){
      float sum=0;
      scanf("%d %d UTC%c%f",&h,&m,&c,&s);
      if(c=='+'){
        sum =(float) h*60+m-(8*60-60*s);
      }
      else{
        sum=(float) h*60+m-(8*60+60*s);
      }
      int sum1;
      sum1=(int)(sum+mod)%mod;

    printf("%02d:%02d\n",sum1/60,sum1%60);


    }
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章