Codeforces Round #419 (Div. 2) A. Karen and Morning(模拟)
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(模拟)的更多相关文章
- 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. 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 ...
- 【找规律】【递推】【二项式定理】Codeforces Round #419 (Div. 1) B. Karen and Test
打个表出来看看,其实很明显. 推荐打这俩组 11 1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 1000000000 ...
- 【贪心】 Codeforces Round #419 (Div. 1) A. Karen and Game
容易发现,删除的顺序不影响答案. 所以可以随便删. 如果行数大于列数,就先删列:否则先删行. #include<cstdio> #include<algorithm> usin ...
- Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...
- Codeforces Round #419 (Div. 2)
1.题目A:Karen and Morning 题意: 给出hh:mm格式的时间,问至少经过多少分钟后,该时刻为回文字符串? 思路: 简单模拟,从当前时刻开始,如果hh的回文rh等于mm则停止累计.否 ...
随机推荐
- Codeforces 603E Pastoral Oddities
传送门:http://codeforces.com/problemset/problem/603/E [题目大意] 给出$n$个点,$m$个操作,每个操作加入一条$(u, v)$长度为$l$的边. 对 ...
- c# Sockect 通信
1.Server using System; using System.Collections.Generic; using System.Text; //添加Socket类 using System ...
- Service简介 demos
extends:http://blog.csdn.net/ithomer/article/details/7364024 一. Service简介 Service是android 系统中的四大组件之一 ...
- dubbo有什么作用
转自:http://blog.csdn.net/ichsonx/article/details/39008519 1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的R ...
- 问答项目---登陆也要做验证!(JS和PHP验证)
简单JS示例: var login = $( 'form[name=login]' ); login.submit( function () { if (validate.loginAccount & ...
- oneThink发生错误,获取当前执行的SQL语句!
echo D('AnswerInfoView')->getLastSql();die();
- 170525、解决maven隐式依赖包版本问题
今天在使用dubbo2.5.3版本的时候,启动项目的时候发现一个问题,tomcat启动一直报错 Caused by: java.lang.IllegalStateException: Context ...
- Oracle等待事件之Latch Free
1.产生原因 表示某个锁存器上发生了竞争.首先应该确保已经提供了足够多的Latch 数,如果仍然发生这种等待事件,那么应该进一步确定是那种锁存器上发生了竞争(在v$session_wait 上的P2 ...
- mybatis-spring-boot-autoconfigure
mybatis-spring-boot-autoconfigure – MyBatis Sring-BootStarter | Reference Documentation http://www.m ...
- Python爬虫实例(五) requests+flask构建自己的电影库
目标任务:使用requests抓取电影网站信息和下载链接保存到数据库中,然后使用flask做数据展示. 爬取的网站在这里 最终效果如下: 主页: 可以进行搜索:输入水形物语 点击标题进入详情页: 爬虫 ...