A. Karen and Morning
time limit per test

2 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

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.

Input

The first and only line of input contains a single string in the format hh:mm (00 ≤  hh  ≤ 23, 00 ≤  mm  ≤ 59).

Output

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.

Examples
input
05:39
output
11
input
13:31
output
0
input
23:59
output
1
Note

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 <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath> using namespace std; #define LL long long
const int inf=0x7fffffff; bool check(int h,int m)
{
if(h/10+(h%10)*10==m)
return 1;
return 0;
}
int main()
{
int h,m;
while(~scanf("%d:%d",&h,&m))
{
int ans=0;
while(!check(h,m))
{
ans++;
m++;
if(m==60)
h+=1,m=0;
if(h==24)
h=0;
}
printf("%d\n",ans); } return 0;
}

或者干脆蠢一点根据时间分类讨论

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath> using namespace std; #define LL long long
const int inf=0x7fffffff; int main()
{
int h,m;
while(~scanf("%d:%d",&h,&m))
{
int t=h*60+m;
int ans;
if(h<5||(h==5&&m<=50))
{
int fm=h*10;
if(m<=fm)
{
ans=fm-m;
}
else
{
fm=(h+1)*10;
ans=(h+1)*60+fm-t;
}
}
else if(h<=9)
{
ans=10*60+1-t;
}
else if(h<15||(h==15&&m<=51))
{
int fm=(h%10)*10+(h/10);
if(m<=fm)
{
ans=fm-m;
}
else
{
fm=((h+1)%10)*10+((h+1)/10);
ans=(h+1)*60+fm-t;
}
}
else if(h<=19)
{
ans=20*60+2-t;
}
else if(h<23||(h==23&&m<=32))
{
int fm=(h%10)*10+(h/10);
if(m<=fm)
{
ans=fm-m;
}
else
{
fm=((h+1)%10)*10+((h+1)/10);
ans=(h+1)*60+fm-t;
}
}
else
{
ans=24*60-t;
}
printf("%d\n",ans);
}
return 0;
}

Codeforces816A Karen and Morning 2017-06-27 15:11 43人阅读 评论(0) 收藏的更多相关文章

  1. SQL 存储过程 分页 分类: SQL Server 2014-05-16 15:11 449人阅读 评论(0) 收藏

    set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go -- ============================================= -- Au ...

  2. save与Update的合并操作 标签: 关系映射 2017-07-13 15:11 7人阅读 评论(0) 收藏

    做save与update的方法合并操作时,判断条件是主体对象的ID是否存在. 但是当页面中,涉及到多个主体对象的关联对象时,情况变得复杂起来,特总结项目中的几点 一.页面中的VO对象属性可以分为三类: ...

  3. 【JAVA编码专题】总结 分类: B1_JAVA 2015-02-11 15:11 290人阅读 评论(0) 收藏

    第一部分:编码基础 为什么需要编码:用计算机看得懂的语言(二进制数)表示各种各样的字符. 一.基本概念 ASCII.Unicode.big5.GBK等为字符集,它们只定义了这个字符集内有哪些字符,以及 ...

  4. 安装hadoop1.2.1集群环境 分类: A1_HADOOP 2014-08-29 15:49 1444人阅读 评论(0) 收藏

    一.规划 (一)硬件资源 10.171.29.191 master 10.173.54.84  slave1 10.171.114.223 slave2 (二)基本资料 用户:  jediael 目录 ...

  5. Hadoop常见异常及其解决方案 分类: A1_HADOOP 2014-07-09 15:02 4187人阅读 评论(0) 收藏

    1.Shell$ExitCodeException 现象:运行hadoop job时出现如下异常: 14/07/09 14:42:50 INFO mapreduce.Job: Task Id : at ...

  6. codeforces815A Karen and Game 2017-06-27 15:22 31人阅读 评论(0) 收藏

    C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard i ...

  7. Codeforces816B Karen and Coffee 2017-06-27 15:18 39人阅读 评论(0) 收藏

    B. Karen and Coffee time limit per test 2.5 seconds memory limit per test 512 megabytes input standa ...

  8. PIE(二分) 分类: 二分查找 2015-06-07 15:46 9人阅读 评论(0) 收藏

    Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  9. Basic 分类: POJ 2015-08-03 15:49 3人阅读 评论(0) 收藏

    Basic Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 905 Accepted: 228 Description The p ...

随机推荐

  1. 使用PreparedStatement时,输出完整的SQL语句

    使用psstmt时不能打印出完整的sql语句,挺不方便的,找到一个实现方法,记录下来. package com.zhh.function.util; import java.io.InputStrea ...

  2. andorid 列表视图 ListView 之ArrayAdapter

    activity_ui3.xml <?xml version="1.0" encoding="utf-8"?> <ListView xmlns ...

  3. Mike and strings 798B

    B. Mike and strings time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. gulp ( http://markpop.github.io/2014/09/17/Gulp入门教程 )

    前言 最近流行前端构建工具,苦于之前使用Grunt,代码很难阅读,现在出了Gulp,真是摆脱了痛苦.发现了一篇很好的Gulp英文教程,整理翻译给大家看看. 为什么使用Gulp Gulp基于Node.j ...

  5. How to update XENTRY Connect C5 software with .iso file

    07.2018 Xentry Mercedes SD Connect c5 software update manual for newbies: Important: If you have XDO ...

  6. What is MaxiSys Pro MS908P Software Advantage

    The Autel Maxisys Pro Diagnostic Platform is an evolutionary smart solution for specialized automoti ...

  7. mysql 查两个表之间的数据差集

    需要查两个表之间的差集 首先,想到的是主键直接not in select mailbox_id from co_user where mailbox_id not in (select mailbox ...

  8. vim窗口切换

    参考资料: http://www.cnblogs.com/litifeng/p/8282479.html 当用vim写代码的时候,我喜欢一边看着头文件中结构的定义,一边编写实现的代码,这样就经常用到多 ...

  9. Elastix GOIP 网关配合

    方案一 Gateway disallow=allallow=alaw&ulawcanreinvite=nodtmfmode=rfc2833host=192.168.1.108insecure= ...

  10. Mac OS X下安装Python的MySQLdb模块【终结版】

    1.下载源文件: https://pypi.org/project/MySQL-python/ 2.cd 到源文件所在目录: 3.在目录下使用 python setup.py install 命令安装 ...