zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 7 B

    Description

    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:59
    10
    output
    00:09
    input
    20:20
    121
    output
    22:21
    input
    10:10
    0
    output
    10:10
    一个简单的模拟
     1 #include<stdio.h>
     2 //#include<bits/stdc++.h>
     3 #include<string.h>
     4 #include<iostream>
     5 #include<math.h>
     6 #include<sstream>
     7 #include<set>
     8 #include<queue>
     9 #include<map>
    10 #include<vector>
    11 #include<algorithm>
    12 #include<limits.h>
    13 #define inf 0x3fffffff
    14 #define INF 0x3f3f3f3f
    15 #define lson l,m,rt<<1
    16 #define rson m+1,r,rt<<1|1
    17 #define LL long long
    18 #define ULL unsigned long long
    19 using namespace std;
    20 int t;
    21 int n,m;
    22 int sum,ans,flag;
    23 int a,b,c,d;
    24 int main()
    25 {
    26     scanf("%d:%d",&a,&b);
    27     scanf("%d",&n);
    28     while(n--)
    29     {
    30         b++;
    31         if(b==60)
    32         {
    33             a++;
    34             b=0;
    35             if(a==24)
    36             {
    37                 a=0;
    38             }
    39         }
    40     }
    41     printf("%02d:%02d",a,b);
    42     return 0;
    43 }
  • 相关阅读:
    LVS DR实验!
    Memcached 与 Redis 区别
    LVS笔试题!
    并发编程拓展知识
    并发编程之协程
    并发编程之线程
    并发编程之多道技术
    粘包问题与socketserver实现并发
    套接字通信
    git的使用
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/5186840.html
Copyright © 2011-2022 走看看