http://codeforces.com/contest/816/problem/A

题意:

给出一个时间,问最少过多少时间后是回文串。

思路:

模拟,先把小时的逆串计算出来:

① 如果逆串=分钟,那么此时已经是回文串了。

② 如果逆串>分钟,那么只需要逆串-分钟即可。(注意此时逆串>=60的情况)

③ 如果逆串<分钟,此时在这个小时内要构成回文串已经是不可能的了,那么就加上60-minute分钟,进入一个新的小时,然后重复上述步骤。

 #include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
const int INF = 0x3f3f3f3f;
const int maxn=*1e5+; char str[]; int main()
{
//freopen("in.txt","r",stdin);
while(~scanf("%s",&str))
{
int hour = (str[]-'')* + (str[]-'');
int minute = (str[]-'')*+(str[]-'');
int rev_h = (str[]-'')*+str[]-'';
int rev_m = (str[]-'')*+(str[]-''); if(hour==rev_m) {puts("");continue;} int ans=;
while(true)
{
rev_h = (hour%*) + hour/;
if(rev_h == minute) break;
if(rev_h>minute && rev_h<)
{
ans+=rev_h-minute;
break;
} else
{
ans+=-minute;
minute=;
hour=(hour+)%;
}
}
printf("%d\n",ans);
}
return ;
}

Codeforces Round #419 (Div. 2) A. Karen and Morning(模拟)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Codeforces Round #419 (Div. 2) E. Karen and Supermarket(树形dp)

    http://codeforces.com/contest/816/problem/E 题意: 去超市买东西,共有m块钱,每件商品有优惠卷可用,前提是xi商品的优惠券被用.问最多能买多少件商品? 思路 ...

  5. Codeforces Round #419 (Div. 1) C. Karen and Supermarket 树形DP

    C. Karen and Supermarket     On the way home, Karen decided to stop by the supermarket to buy some g ...

  6. 【找规律】【递推】【二项式定理】Codeforces Round #419 (Div. 1) B. Karen and Test

    打个表出来看看,其实很明显. 推荐打这俩组 11 1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 1000000000 ...

  7. 【贪心】 Codeforces Round #419 (Div. 1) A. Karen and Game

    容易发现,删除的顺序不影响答案. 所以可以随便删. 如果行数大于列数,就先删列:否则先删行. #include<cstdio> #include<algorithm> usin ...

  8. Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)

    Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...

  9. Codeforces Round #419 (Div. 2)

    1.题目A:Karen and Morning 题意: 给出hh:mm格式的时间,问至少经过多少分钟后,该时刻为回文字符串? 思路: 简单模拟,从当前时刻开始,如果hh的回文rh等于mm则停止累计.否 ...

随机推荐

  1. gradle下的第一个SpringMVC应用

    新建gradle project 缺少了很多文件夹和文件,我们自己补充,补充完的目录如下: HelloController: package controller; import javax.serv ...

  2. JavaScript获取地址栏的参数!

    第一种方式:手动解析 “location”对象 console.log(window.location); 使用这个对象做跳转: window.location.href=""; ...

  3. hdu4975 网络流解方程组(网络流+dfs判环或矩阵DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=4975 A simple Gaussian elimination problem. Time Limit: 20 ...

  4. explain 分析 聚合统计语句的性能

    EXPLAIN SELECT COUNT(1) FROM question; id select_type table partitions type possible_keys key key_le ...

  5. MySQL插入性能优化(转)

    原文:http://tech.uc.cn/?p=634 对于一些数据量较大的系统,数据库面临的问题除了查询效率低下,还有就是数据入库时间长.特别像报表系统,每天花费在数据导入上的时间可能会长达几个小时 ...

  6. 寻找最小(最大)的k个数

    题目描述:输入n个整数,输出其中最小的k个元素. 例如:输入1,2,3,4,5,6,7,8这8个数字,则最小的4个数字为1,2,3,4. 思路1:最容易想到的方法:先对这个序列从小到大排序,然后输出前 ...

  7. vsftpd文件服务器安装与配置

    -d<登入目录>:指定用户登入时的启始目录:. -s<shell>:指定用户登入后所使用的shell: /sbin/nologin指的是不允许login当前Linux系统.当用 ...

  8. Struts2表单数据接收方式

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/sunshoupo211/article/details/30249239 1.将Action类作 ...

  9. centos LAMP第四部分mysql操作 忘记root密码 skip-innodb 配置慢查询日志 mysql常用操作 mysql常用操作 mysql备份与恢复 第二十二节课

    centos  LAMP第四部分mysql操作  忘记root密码  skip-innodb 配置慢查询日志 mysql常用操作  mysql常用操作 mysql备份与恢复   第二十二节课 mysq ...

  10. centos7上安装php5.6

    配置yum源 追加CentOS 6.5的epel及remi源. # rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel- ...