2018HDU多校联赛第一场Time Zone

题目衔接:http://acm.hdu.edu.cn/showproblem.php?pid=6308

Time Zone

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


 

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

2018 Multi-University Training Contest 1

题目大意:给你时间,让你求出在经过多少个时区后的时间,

思路:没有思路,就是直接算

代码:

#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int N=4e6+10;
char time[10];
int a[N],b[N];
int main()
{
    int test;
    scanf("%d",&test);
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    while(test--)
    {
        int i,j,l,k=0,x=0;
        int hour,minute;
        double y=0.0;
        scanf("%d%d",&hour,&minute);
        scanf("%s",time);
        l=strlen(time);
        for(i=4; i=60)
            {
                minute-=60;
                hour+=1;
            }
            if(hour<0)
            {
                hour+=24;
            }
        }
        else if(time[3]=='-')
        {
            x+=8;
            hour-=x;
            minute-=(int)y;
            if(minute<0)
            {
                hour-=1;
                minute+=60;
            }
            if(minute>=60)
            {
                minute-=60;
                hour+=1;
            }
            if(hour<0)
            {
                hour+=24;
            }
        }
        if(hour>=24)
        {
            hour-=24;
        }
        hour>9?printf("%d:",hour):printf("0%d:",hour);
        minute>9?printf("%d\n",minute):printf("0%d\n",minute);
    }

    return 0;
}

 

你可能感兴趣的:(题补)