Educational Codeforces Round 7--B. The Time

来源:互联网 发布:jira 安装 mysql 编辑:程序博客网 时间:2024/05/16 15:23
B. The Time
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given the current time in 24-hour format hh:mm. Find and print the time after a minutes.

Note that you should find only the time after a minutes, see the examples to clarify the problem statement.

You can read more about 24-hour format here https://en.wikipedia.org/wiki/24-hour_clock.

Input

The first line contains the current time in the format hh:mm (0 ≤ hh < 24, 0 ≤ mm < 60). The hours and the minutes are given with two digits (the hours or the minutes less than 10 are given with the leading zeroes).

The second line contains integer a (0 ≤ a ≤ 104) — the number of the minutes passed.

Output

The only line should contain the time after a minutes in the format described in the input. Note that you should print exactly two digits for the hours and the minutes (add leading zeroes to the numbers if needed).

See the examples to check the input/output format.

Sample test(s)
input
23:5910
output
00:09
input
20:20121
output
22:21
input
10:100
output
10:10
大体题意:
给你现在的时间,在给你一个分钟数n,求现在的时间过上n分钟后的时间。
思路很清晰:
1.把分钟数n先变成   小时:分钟  的格式。
2.在对应和现在的时间相加。分钟满60进1,小时对24取余即可。

代码如下:
#include<bits/stdc++.h>#define mem(x) memset(x,0,sizeof(x));#define mem1(x) memset(x,-1,sizeof(x));using namespace std;const double eps = 1e-8;const int INF = 1e8;const int maxn = 10000 + 10;const int maxt = 100 + 10;typedef long long ll;typedef unsigned long long llu;int main(){    int h,m;    while(scanf("%d:%d",&h,&m) == 2){        int mm;        cin >> mm;        int lef_h = mm/60;        int lef_m = mm-(mm/60)*60;        int flag = 0;        int res_m,res_h;        res_m=m+lef_m;        if (res_m>=60){            flag=res_m/60;            res_m=res_m%60;        }        res_h=(h+lef_h+flag)%24;        cout << res_h/10 << res_h%10 << ":"<<res_m/10 << res_m%10 << endl;    }    return 0;}


0 0