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. 【黑金ZYNQ7000系列原创视频教程】03.体验FPGA里的ARM——裸机helloworld实验

    黑金论坛地址: http://www.heijin.org/forum.php?mod=viewthread&tid=36637&extra=page%3D1 爱奇艺地址: http: ...

  2. iOS使用位置和方向服务(来自苹果apple官方)

    版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[+]   本文章来自苹果官方文档,特此声明--------禚 Core Location框架为定位用户当前位置和方向(Headin ...

  3. HDCMS做异步加载!

    控制器的写法: //ajax 请求新闻列表 public function ajaxnewsList(){ $data = Q('sum'); $newsList = M('xinwen')-> ...

  4. c++Template 的辨析

    1.在c++Template中很多地方都用到了typename与class这两个关键字,而且好像可以替换,是不是这两个关键字完全一样呢? 答:class用于定义类,在模板引入c++后,最初定义模板的方 ...

  5. 单机器启动多个tomcat的配置修改

    首先去apache下载一个tomcat,下载解压版的,比较方便   把这个tomcat(我下载的是tomcat7版本),解压两次,为了方便显示,我把解压出来的tomcat重命名成tomcat71和to ...

  6. nginx中文乱码问题

    搭建nginx成功后,在页面中写入了中文字幕,结果发现乱码 于是修改了nginx配置文件nginx.conf:如下 server { listen ; server_name example.com; ...

  7. codeforces #516---ABC

    A---golden plate http://codeforces.com/contest/1072/problem/A 题意:给一个n*m的格子,从最外层往里涂色,每次尽量涂最外面的那一圈,两圈涂 ...

  8. 点击劫持漏洞解决( Clickjacking: X-Frame-Options header missing)

    点击劫持漏洞 X-Frame-Options HTTP 响应头, 可以指示浏览器是否应该加载一个 iframe 中的页面. 网站可以通过设置 X-Frame-Options 阻止站点内的页面被其他页面 ...

  9. 洛谷P1156 垃圾陷阱 dp

    正解:dp 解题报告: 这儿是传送门! 话说最近怎么神仙们都开始狂刷dp,,,感觉今天写了好多dp的题解的样子?(也就三四道其实× 然后这题,首先看到要么吃要么堆起来就会想到01背包趴?然后就考虑设方 ...

  10. 【Python】接口自动化测试-Fidder的使用(未完待续……)

    一.fidder一些一定需要掌握的知识. 1.工具简介 2.清屏操作(1中提到了,这里再着重说明下): 3.get和post请求参数相关: 4.会话框(Fidder左侧区域内容解析): 5.Reque ...