【2018多校第一场】hdu6308-Time Zone(日期)

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
 

 

【题意】
给出UTC+8的小时a和分钟b,求 "UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y''的日期是多少。
 
//转化成分钟计算
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    int t, h, m;
    char s[10];
    cin>>t;
    while(t--)
    {
        scanf("%d%d%s", &h, &m, s);
        h = h*60+m;
        int op = s[3]=='+'?1:-1;
        double x;
        sscanf(s+4, "%lf", &x);
        x = (int)(x*10+0.005); //读浮点数会有误差
        int cha = x*6*op-8*60;
        h = (h+cha)%(24*60);
        if(h < 0) h += 24*60;
        printf("%02d:%02d\n", h/60, h%60);
    }
    return 0;
}

转载于:https://www.cnblogs.com/lesroad/p/9367963.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值