codeforces round #419 A. Karen and Morning
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, because 05: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<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[];int n;
bool check()
{
int l=,r=n;
while(l<r)
{
if(s[l]!=s[r])return false;
l++;r--;
}
return true;
}
int main()
{
scanf("%s",s+);
n=strlen(s+);
int ans=;
while()
{
if(check())
{
printf("%d",ans);
return ;
}
s[]++;ans++;
if(s[]==''+)s[]='',s[]++;
if(s[]=='')s[]='',s[]++;
if(s[]==''+ && s[]<='')s[]++,s[]='';
if(s[]=='' && s[]=='')s[]='',s[]='';
}
return ;
}
codeforces round #419 A. Karen and Morning的更多相关文章
- Codeforces Round #419 D. Karen and Test
Karen has just arrived at school, and she has a math test today! The test is about basic addition an ...
- codeforces round #419 E. Karen and Supermarket
On the way home, Karen decided to stop by the supermarket to buy some groceries. She needs to buy a ...
- codeforces round #419 C. Karen and Game
C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard i ...
- codeforces round #419 B. Karen and Coffee
To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...
- Codeforces Round #419 (Div. 2) B. Karen and Coffee(经典前缀和)
http://codeforces.com/contest/816/problem/B To stay woke and attentive during classes, Karen needs s ...
- Codeforces Round #419 (Div. 2) C. Karen and Game
C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard i ...
- Codeforces Round #419 (Div. 2) B. Karen and Coffee
To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...
- Codeforces Round #419 (Div. 2) E. Karen and Supermarket(树形dp)
http://codeforces.com/contest/816/problem/E 题意: 去超市买东西,共有m块钱,每件商品有优惠卷可用,前提是xi商品的优惠券被用.问最多能买多少件商品? 思路 ...
- Codeforces Round #419 (Div. 2) A. Karen and Morning(模拟)
http://codeforces.com/contest/816/problem/A 题意: 给出一个时间,问最少过多少时间后是回文串. 思路: 模拟,先把小时的逆串计算出来: ① 如果逆串=分钟, ...
随机推荐
- NO.7 项目需求分析
NO.7 项目需求分析 由于我们组的第一次选题并没有通过,所以我们又重新选择了一个题目--高校学生征信系统. 结合老师的作业要求,我们对该项目进行了详细的需求分析,软件需求规格说明书地址请点击这里.软 ...
- mahony互补滤波器C编程
//gx...分别为重力加速度在三个轴向的分力 由加速度计测得 //ax...分别为角速度在三个轴向的角速度 由陀螺仪测得 //最后得到最终滤波完毕的x.y.z方向的角度值(°) void IMUup ...
- DOM相关知识
一.查找元素 间接查找 parentNode // 父节点 childNodes // 所有子节点 firstChild // 第一个子节点 lastChild // 最后一个子节点 nextSibl ...
- python解释NTFS runlist的代码(文章转自北亚数据恢复张宇工程师)
代码如下: 执行效果如下:root@zhangyu-VirtualBox:~/NTFS-5# python3 read_runlist.py mft_source.img ***参数数量或格式错误! ...
- python之路--day6---文件处理
一.文件 1.文件就是操作系统提供给应用程序来操作硬盘虚拟概念,用户或应用程序通过操作文件, 可以将自己的数据永久保存下来. 2.操作流程 #1. 打开文件,得到文件句柄并赋值给一个变量--f = o ...
- JAVA_SE基础——55.自定义异常类
在Java中已经提供了大量的异常类,但是这些异常类有时野很难满足开发者的要求,所以用户可以根据自己的需要来定义自己的异常类.但自定义的异常类必须继承自Exception或其子类. 可以自定义出的问题称 ...
- Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允许有内容。
Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber ...
- centos6.5中rpm包安装mysql5.7(初始化出错如何解决)
下载rpm包见:http://www.cnblogs.com/grey-wolf/p/7472680.html 1.rz上传到服务器,解压缩 rz [root@mini2 upload]# -.el6 ...
- Vue框架下的node.js安装教程
Vue框架下的node.js安装教程 python服务器.php ->aphche.java ->tomcat. iis -->它是一个可以运行JAVASCRIPTR 的运行环 ...
- Nginx配置特定二级域名
首先把先在域名设置页面把二级域名解析到服务器的公网IP上,这里假设是 bbs.domainname.com 然后编辑 /etc/nginx/sites-available/domain.com.con ...