codeforces 622B B. The Time
1 second
256 megabytes
standard input
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.
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.
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.
23:59
10
00:09
20:20
121
22:21
10:10
0
10:10
题意:问从起点时间经过所给的时间,终点时间是多少;
思路:将时间都转换成分钟;
AC代码:
#include <bits/stdc++.h>
using namespace std;
char str[8];
int a;
int main()
{
scanf("%s",str);
scanf("%d",&a);
int x1,x2;
x1=(str[0]-'0')*10+(str[1]-'0');
x2=(str[3]-'0')*10+(str[4]-'0');
//cout<<x1<<":"<<x2<<"\n";
x2+=a;
x1+=x2/60;
x2%=60;
x1%=24;
if(x1<10)printf("0%d:",x1);
else printf("%d:",x1);
if(x2<10)printf("0%d\n",x2);
else printf("%d\n",x2);
return 0;
}
codeforces 622B B. The Time的更多相关文章
- Codeforces 622B The Time 【水题】
B. The Time time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- CodeForces 622B The Time
水题. #include <stdio.h> #include <algorithm> #include <string.h> #include <queue ...
- codeforces622B
The Time CodeForces - 622B 给你当前的时间(24小时制):HH:MM.输出 x 分钟后的时间是多少?(24小时制) 不明白可以看看例子哦- Input 第一行给出了当前时间, ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- AliRedis性能
引言: 如今redis凭借其高性能的优势, 以及丰富的数据结构作为cache已越来越流行, 逐步取代了memcached等cache产品, 在Twitter,新浪微博中广泛使用,阿里巴 ...
- VC++ 读写注冊表,注冊文件图标关联
#include <string> #include <iostream> #include <Windows.h> #include <shlobj.h&g ...
- local variable 'xxx' referenced before assignment(犯过同样的错)
这个问题很囧,在外面定义了一个变量 xxx ,然后在Python的一个函数里面引用这个变量,并改变它的值,结果报错local variable 'xxx' referenced before assi ...
- 自定义 ViewController 容器转场
本文转载至 http://blog.csdn.net/yongyinmg/article/details/40621463 在话题 #5 中,Chris Eidhof 向我们介绍了 iOS7 引入的新 ...
- sgu Theodore Roosevelt【判断点是否在凸多边形内模板】
链接: http://acm.sgu.ru/problem.php?contest=0&problem=253 http://acm.hust.edu.cn/vjudge/contest/vi ...
- STM32 ~ J-LINK V8 修复
1.1 安装固件烧录软件 ♦请ATMEL官方网址下载AT91-ISP下载软件. 软件下载地址:http://www.atmel.com/dyn/products/tools_card.asp?t ...
- Python基础(1)_python介绍、简单运算符
Python执行一个程序分为三个阶段 阶段一:先启动python解释器 阶段二:python解释器把硬盘中的文件读入到内存中 阶段三:python解释器解释执行刚刚读入内存的代码 二.编程语言的分类: ...
- SpringBoot学习笔记(7):Druid使用心得
SpringBoot学习笔记(7):Druid使用心得 快速开始 添加依赖 <dependency> <groupId>com.alibaba</groupId> ...
- yii 资料
https://github.com/forecho/awesome-yii2 会随时更新 链接:http://pan.baidu.com/s/1mgCKtUK 密码:t6t1 与<YII框架& ...
- 每天一个Linux命令(22)find命令_命令详解
find命令的一些常用参数的常用实例和用时的注意事项. 实例: (1)-name参数: 1)[sunjimeng@localhost home]$ find ~ -name & ...