该浏览器不支持canvas

HDU6308-2018ACM暑假多校联合训练1011-Time Zone

题目大意就是给你UTC-8时区的时间 让你求对应时区的时间
哇 这个题 看似简单,但是一开始怎么都过不了啊
同学用自己写的read过了,后来看了一下各位大佬说改成分钟随便过,就随便过了
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 (1T106), indicating the number of test cases. For each test case:
The first line contains two integers ab (0a23,0b59) and a string s in the format of "UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y'' (0X,X.Y14,0Y9).
 

 

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 <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int t;
    scanf("%d", &t);

    while (t--)
    {
        int p, q;
        float f=0.0;
        char s[10];
        char s1[10];
        scanf("%d %d %s", &p, &q, s);
        sscanf(s + 4,"%f",&f);
        f += 0.01;
        if (s[3] == '-')
            f = -f;
        int num = p * 60 + q - 8 * 60;
        p = f * 60.0;
        num += p;
        if (num < 0)
            num += 1440;
        else if (num >= 1440)
            num -= 1440;

        p = num / 60;
        q = num - p * 60;
        printf("%02d:%02d\n", p, q);
    }

    return 0;
}

 

posted @ 2018-07-23 21:31  真是啰嗦  阅读(177)  评论(0)    收藏  举报