codeforces622B

The Time

 CodeForces - 622B 

给你当前的时间(24小时制):HH:MM。输出 x 分钟后的时间是多少?(24小时制)

不明白可以看看例子哦~

Input

第一行给出了当前时间,格式为: HH:MM (0 ≤ HH < 24, 0 ≤ MM < 60). 小时和分钟都给了两位数, 如果其小于10会给出前导0,例如 01:01

第二行会给出一个整数x (0 ≤ x ≤ 104) ——即输出x分钟后的时间

Output

输出一行,以输入的格式,输出x分钟后的时间,如果其小于10,不要忘了加前导0。

不明白可以看看例子哦~

Example

Input
12:00
69
Output
13:09

sol:模拟的时候要细心,考虑全面,很容易挂掉的qaq
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
    ll s=0;
    bool f=0;
    char ch=' ';
    while(!isdigit(ch))
    {
        f|=(ch=='-'); ch=getchar();
    }
    while(isdigit(ch))
    {
        s=(s<<3)+(s<<1)+(ch^48); ch=getchar();
    }
    return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
    if(x<0)
    {
        putchar('-'); x=-x;
    }
    if(x<10)
    {
        putchar(x+'0'); return;
    }
    write(x/10);
    putchar((x%10)+'0');
    return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('
')
int main()
{
    int X,Y,Time;
    R(X); R(Y);
    Time=read()%(60*24);
    Y=Y+(Time%60);
    X=(X+Time/60)%24;
    if(Y>=60) {X=(X+1)%24; Y-=60;}
    if(X<10) putchar('0'); write(X);
    putchar(':');
    if(Y<10) putchar('0'); write(Y);
    return 0;
}
/*
input
20:20
121
output
22:21

input
02:59
1
output
03:00 
*/ 
View Code
 
原文地址:https://www.cnblogs.com/gaojunonly1/p/10611179.html