codeforces 816A Karen and Morning
来源:互联网 发布:网络设计是什么级别 编辑:程序博客网 时间:2024/06/01 10:19
Karen is getting ready for a new school day!
It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.
What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?
Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.
The first and only line of input contains a single string in the format hh:mm (00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59).
Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.
05:39
11
13:31
0
23:59
1
In the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.
In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.
In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome.
#include <iostream>#include <string>#include <cstdio>#include <algorithm>#include <string>#include <cmath>#include <cstring>using namespace std;const int MAXN=5000+10;int h,m;int main(){ scanf("%d:%d",&h,&m); for(int i=0;i<=10000000;i++){ if(m%10==h/10&&m/10==h%10){ printf("%d\n",i); break; } h=(h+(m+1)/60)%24; m=(m+1)%60; }}
- Codeforces 816A-Karen and Morning
- codeforces 816A Karen and Morning
- CodeForces 816A Karen and Morning
- codeforces A Karen and Morning 傻瓜模拟
- A. Karen and Morning
- Codeforces Round #419 (Div. 2) A. Karen and Morning
- cf419 A Karen and Morning
- CodeForce Round #479 A. Karen and Morning
- CF816A-Karen and Morning
- Karen and Morning
- Codeforces816A Karen and Morning
- Karen and Morning
- Karen and Morning
- Codeforces Round #419 A. Karen and Game
- Codeforces 815A-Karen and Game
- Karen and Coffee codeforces 816B
- Karen and Game codeforces 816c
- Codeforces 816C Karen and Game【思维】
- oracleday01(基本语法 口令管理)
- java中如何去掉\,/字符
- 【Android】EasyClient与EasyCamera的移植学习
- 使用while语句,分别求1到100的奇数和 和 偶数和
- 轻松实现圆角图片
- codeforces 816A Karen and Morning
- SSH 原理与运用:如何远程自动免密码登录
- 购物车
- C语言:一维数组数组
- HM代码中Z-order扫描和Raster扫描之间的地址映射问题
- Android JS解析引擎 Rhino 使用笔记(不借助webview)
- 周一日记
- Java_基础—字节流读写中文
- 快速提高 CSDN 访问量