A. Karen and Morning
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, 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<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int cnt;
bool judge(int a,int b)
{
if(a/==b%&&a%==b/)return ;
else return ;
}
int main()
{
int a,b;
scanf("%d:%d",&a,&b);
if(judge(a,b)){cout<<;return ;}
while(!judge(a,b))
{
b++;
cnt++;
if(b==){a++;b=;}
if(a==){a=;}
}
cout<<cnt;
return ;
}
A. Karen and Morning的更多相关文章
- B. Karen and Coffee
B. Karen and Coffee time limit per test 2.5 seconds memory limit per test 512 megabytes input standa ...
- C. Karen and Game
C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard i ...
- CodeForces 816B Karen and Coffee(前缀和,大量查询)
CodeForces 816B Karen and Coffee(前缀和,大量查询) Description Karen, a coffee aficionado, wants to know the ...
- codeforces 815C 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 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 #460 D. Karen and Cards
Description Karen just got home from the supermarket, and is getting ready to go to sleep. After tak ...
- 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 A. Karen and Morning
Karen is getting ready for a new school day! It is currently hh:mm, given in a 24-hour format. As yo ...
随机推荐
- php学习之string
1. php str_replace函数: str_replace() 函数使用一个字符串替换字符串中的另一些字符. str_replace(find,replace,string,count) fi ...
- 每天一道Java题[1]
问题:char[]与String相比,有什么优胜的地方? 回答: 针对安全保密高的信息,char[]比String做得更好.因为String是不可变得,即使你修改原先的变量,实际上也是在内存中新建一个 ...
- JSP页面的静态包含和动态包含
JSP中有两种包含:静态包含:<%@include file="被包含页面"%>和动态包含:<jsp:include page="被包含页面" ...
- Sqlla: 数据库操作从未如此简单
Sqlla 一套数据库的 ORM 微型库,提供简单高效的 API 来操作数据库. Sqlla 拥有极少的API,使用方式简单.让开发者不需要关心数据库操作的具体细节,只需专注SQL和业务逻辑.同时简单 ...
- 通过vmware 启动cloudera-quickstart-vm-5.10.0-0-vmware.zip镜像无法启动。
解压cloudera-quickstart-vm-5.10.0-0-vmware.zip中找到cloudera-quickstart-vm-5.10.0-0-vmware.vmx文件打开注释点#msg ...
- C#基础知识-编程思想之封装(七)
既然是学习面向对象的编程那自然要了解面向对象中的三大基石,封装.继承和多态. 我觉得要解释这三大基本概念用一篇文档很难解释清楚,想要具体形象的去了解,还是需要每一个概念用一个篇幅来说明,将封装.继承和 ...
- 基于OWIN+DotNetOpenOAuth实现OAuth2.0
这几天时间一直在研究怎么实现自己的OAuth2服务器,对于太了解OAuth原理以及想自己从零开始实现的,我建议可以参考<Apress.Pro ASP.NET Web API Security&g ...
- UITextField关闭自动联想功能
在textField输入内容时,如果内容为英文,输入的英文如果不正确的单词就是有红色的线报警,关闭英文自动联想功能 self.autocorrectionType = UITextAutocorrec ...
- SpringMVC 3.2集成Spring Security 3.2
参考:http://www.cnblogs.com/Beyond-bit/p/springmvc_and_springsecurity.html SpringMVC 3.2集成Spring Secur ...
- javaWeb学习总结(1)- Tomcat服务器学习和使用(3)
一.打包JavaWeb应用 在Java中,使用"jar"命令来对将JavaWeb应用打包成一个War包,jar命令的用法如下: