1.题目A:Karen and Morning

题意:

给出hh:mm格式的时间,问至少经过多少分钟后,该时刻为回文字符串?

思路:

简单模拟,从当前时刻开始,如果hh的回文rh等于mm则停止累计。否则,根据rh和mm的大小来累计sum,然后hh+1,不断尝试。

 #include<iostream>
using namespace std;
int main()
{
int hh,mm;
char c;
while (cin >> hh >> c >> mm)
{
int sum = ;
bool firsthour = true;
while ()
{
int rh = hh % * + hh / ;
if (rh == mm) break;
else
{
if (rh < )
{
if (firsthour)
{
firsthour = false;
if (rh >= mm)
{
sum += rh - mm;
break;
}
else
{
sum += - mm;
mm = ;
hh = (hh + ) % ;
}
}
else
{
sum += rh;
break;
}
}
else
{
if (firsthour) sum += - mm,mm=,firsthour=false;
else sum += ;
hh = (hh + ) % ;
} }
}
cout << sum << endl;
}
return ;
}

A. Karen and Morning

2.题目B: Karen and Coffee

题意:

给出n个已知区间,然后询问q个区间,问询问区间中至少被k个已知区间包含的点为几个。

思路:

一开始想着对每个已知区间中的值累加,然后对每次询问[l,r],遍历l——r,妥妥超时~~

然后看了些大神的代码,首先不必要对每个已知区间中的值累加,只要在已知区间的开始和结束的位置做标记,然后对于查询,可以预处理用前缀和来记录1~i满足条件的数目,然后O(1)便能得出答案。还有的巨巨用线段树来维护,至少比O(n)的时间少,应该是O(logn)吧。。。

下面给出巨巨的链接:

线段树实现

前缀和实现

Codeforces Round #419 (Div. 2)的更多相关文章

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

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

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

  3. Codeforces Round #419 (Div. 2) A. Karen and Morning(模拟)

    http://codeforces.com/contest/816/problem/A 题意: 给出一个时间,问最少过多少时间后是回文串. 思路: 模拟,先把小时的逆串计算出来: ① 如果逆串=分钟, ...

  4. Codeforces Round #419 Div. 1

    A:暴力枚举第一列加多少次,显然这样能确定一种方案. #include<iostream> #include<cstdio> #include<cmath> #in ...

  5. Codeforces Round #419 (Div. 2) ABC

    python 2.7,用来熟悉Python 由于都是智障题,所以我也不讲述题意和题解,直接贴代码了-- A import sys h,m = map(int,raw_input().split(&qu ...

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

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

  8. Codeforces Round #419 (Div. 2)(B)差分数组

    传送门:Problem B https://www.cnblogs.com/violet-acmer/p/9721160.html 题意: Karen有n个关于煮咖啡的食谱,每个食谱都有个煮咖啡的最适 ...

  9. Codeforces Round #419 (Div. 2) A B C 暴力 区间更新技巧 +前缀和 模拟

    A. Karen and Morning time limit per test 2 seconds memory limit per test 512 megabytes input standar ...

随机推荐

  1. JS判断当前手机类型

    window.onload = function () { var u = navigator.userAgent; if (u.indexOf('Android') > -1 || u.ind ...

  2. ConcurrentHashMap、HashTable、HashMap的区别

    HashTable与ConcurrentHashMap: 相同点:都是线程安全的,可以在多线程的环境下运行.key和value都不能为null 区别:性能上的差异.HashTable每次操作对象都会锁 ...

  3. 2017TSC世界大脑与科技峰会,多角度深入探讨关于大脑意识

    TSC·世界大脑与科技峰会是全世界范围内的集会,多角度深入探讨关于大脑意识体验来源这一根本话题,我们是谁,现实的本质是什么,我们所处宇宙空间的本质为何.该峰会由亚利桑那大学意识研究中心主办. 会议时间 ...

  4. MySQL索引及查询优化总结

    欢迎大家关注腾讯云技术社区-博客园官方主页,我们将持续在博客园为大家推荐技术精品文章哦~ 作者:谢庆玲 文章<MySQL查询分析>讲述了使用MySQL慢查询和explain命令来定位mys ...

  5. 大数据和BI商业智能有何区别?有何相关?

    大数据 ≠BI商业智能,大数据也不是传统商业智能的简单升级. 1.大数据和BI两者的区别 BI(BusinessIntelligence)即商业智能,它是企业数据化管理的一整套的方案,用来将企业中现有 ...

  6. Visual Studio for Mac 初体验

    你喜爱的 IDE,现在可用于 Mac 来自:https://www.visualstudio.com/zh-hans/vs/visual-studio-mac/ 惊不惊喜?意不意外?惊喜但不意外,因为 ...

  7. Win10更新补丁失败后出现无法更新正在撤销 解决办法

    系统更新失败,反复重启还是不行,那是不是下载下来的补丁没用了呢??所以我们先要删除Windows更新的缓存文件!在做以下操作之前,首先我们要确认系统内的windows update & BIT ...

  8. spring-boot整合dubbo:Spring-boot-dubbo-starter

    为什么要写这个小工具 如果你用过Spring-boot来提供dubbo服务,相信使用中有很多"不爽"的地方.既然使用spring boot,那么能用注解的地方绝不用xml配置,这才 ...

  9. AngularJS操作DOM——angular.element

    addClass()-为每个匹配的元素添加指定的样式类名 after()-在匹配元素集合中的每个元素后面插入参数所指定的内容,作为其兄弟节点 append()-在每个匹配元素里面的末尾处插入参数内容a ...

  10. 深入解析java String中getBytes()的编码问题

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6900536.html Java服务器后台在和Android端App通信时,遇到了两端关于用MD5加密同一包含 ...