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. 九思,OA协同九大设计要点

    伴随着产品线的丰富和客户数量的增加,我们发现烂尾项目也与日俱增,客户和OA公司之间的矛盾日益尖锐,一套好OA系统远非增加几个特色功能这么简单,套用孔子"君子有九思"的话,好的OA系 ...

  2. 像写C#一样编写java代码

    JDK8提供了非常多的便捷用法和语法糖,其编码效率几乎接近于C#开发,maven则是java目前为止最赞的jar包管理和build工具,这两部分内容都不算多,就合并到一起了. 愿编写java代码的过程 ...

  3. Xcode旧项目引入CocoaPod遇到的问题与解决

    html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...

  4. Spring+SpringMVC+MyBatis深入学习及搭建(一)——MyBatis的基础知识

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6812311.html 1.对原生态jdbc程序中问题总结 1.1 jdbc程序 需求:使用jdbc查询mys ...

  5. Unable open dabase as spfile parameter incorrect

    Error desc: ORA-00821: Specified value of sga_target 16M is too small, needs to be at least 4832M   ...

  6. servlet的过滤器的doFilter()

    doFilter中的chain.doFilter(res,req);//Filter 只是链式处理,请求依然转发到目的地址 意思就说过滤器只是一个关口,如果符合条件的请求会被过滤器拦截下来,然后进行处 ...

  7. 最全DOS的CMD命令,程序员必会

    CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本.文件系统版本)1. appwiz.cpl:程序和功能 2. calc:启动计算器 3. certmgr. ...

  8. Vuejs实例-02Vue.js项目集成ElementUI

    Vuejs实例-02Vue.js项目集成ElementUI 0:前言 vue.js的UI组件库,在git上有多个项目,我见的使用者比较多的是iView和Element.两个组件库,组件都很丰富. 官网 ...

  9. Bootstrap实现轮播图

    第一步:设计轮播图容器:div.carousel,添加slide平滑切换,并定义id,方便后面采用data属性来触发 <div class='carousel slide' id="t ...

  10. css浮动--float/clear通俗讲解(转载)

    本文为转载 (出处:http://www.cnblogs.com/iyangyuan/archive/2013/03/27/2983813.html) 教程开始: 首先要知道,div是块级元素,在页面 ...