time limit per test  2 seconds
memory limit per test  512 megabytes
 

Karen is getting ready for a new school day!

It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.

What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?

Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.

Input

The first and only line of input contains a single string in the format hh:mm (00 ≤  hh  ≤ 23, 00 ≤  mm  ≤ 59).

Output

Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.

 
input
05:39
output
11
input
13:31
output
0
input
23:59
output
1
Note
In the first test case, the minimum number of minutes Karen should sleep for is . She can wake up at :, when the time is a palindrome. In the second test case, Karen can wake up immediately, as the current time, :, is already a palindrome. In the third test case, the minimum number of minutes Karen should sleep for is minute. She can wake up at :, when the time is a palindrome.

Note:

题目大意:

    输入一个时间,判断多少时间之后能够组成一个回文串

解题思路:

    按照时间的运算法则,一分钟一分钟的增加,每增加一分钟就判断一次,直到组成回文时间

AC代码:

 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std; int main()
{
int h,m;
while (~scanf("%d:%d",&h,&m))
{
int sum = ;
while (h/ != m% || h% != m/){
m ++;
if (m == )
{
m = ; h ++;
}
if (h == )
h = ;
sum ++;
}
printf("%d\n",sum);
}
return ;
}
time limit per test  2.5 seconds
memory limit per test  512 megabytes
 

To stay woke and attentive during classes, Karen needs some coffee!

Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".

She knows n coffee recipes. The i-th recipe suggests that coffee should be brewed between li and ri degrees, inclusive, to achieve the optimal taste.

Karen thinks that a temperature is admissible if at least k recipes recommend it.

Karen has a rather fickle mind, and so she asks q questions. In each question, given that she only wants to prepare coffee with a temperature between a and b, inclusive, can you tell her how many admissible integer temperatures fall within the range?

Input

The first line of input contains three integers, nk (1 ≤ k ≤ n ≤ 200000), and q (1 ≤ q ≤ 200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively.

The next n lines describe the recipes. Specifically, the i-th line among these contains two integers li and ri (1 ≤ li ≤ ri ≤ 200000), describing that the i-th recipe suggests that the coffee be brewed between li and ri degrees, inclusive.

The next q lines describe the questions. Each of these lines contains a and b, (1 ≤ a ≤ b ≤ 200000), describing that she wants to know the number of admissible integer temperatures between a and b degrees, inclusive.

Output

For each question, output a single integer on a line by itself, the number of admissible integer temperatures between a and b degrees, inclusive.

 
input
3 2 4
91 94
92 97
97 99
92 94
93 97
95 96
90 100
output
3
3
0
4
input
2 1 1
1 1
200000 200000
90 100
output
0
In the first test case, Karen knows  recipes.

The first one recommends brewing the coffee between  and  degrees, inclusive.
The second one recommends brewing the coffee between and degrees, inclusive.
The third one recommends brewing the coffee between and degrees, inclusive.
A temperature is admissible if at least recipes recommend it. She asks questions. In her first question, she wants to know the number of admissible integer temperatures between and degrees, inclusive. There are : , and degrees are all admissible. In her second question, she wants to know the number of admissible integer temperatures between and degrees, inclusive. There are : , and degrees are all admissible. In her third question, she wants to know the number of admissible integer temperatures between and degrees, inclusive. There are none. In her final question, she wants to know the number of admissible integer temperatures between and degrees, inclusive. There are : , , and degrees are all admissible. In the second test case, Karen knows recipes. The first one, "wikiHow to make Cold Brew Coffee", recommends brewing the coffee at exactly degree.
The second one, "What good is coffee that isn't brewed at at least 36.3306 times the temperature of the surface of the sun?", recommends brewing the coffee at exactly degrees.
A temperature is admissible if at least recipe recommends it. In her first and only question, she wants to know the number of admissible integer temperatures that are actually reasonable. There are none.

Note:


题目大意: 
      给出n个配料区间,q个查询区间,问每次查询时,该查询区间内有多少个点至少被k个配料区间覆盖。 解题思路:
     预处理+前缀数组 一共三个数组
.第一个循环后S[i]表示i点被覆盖的次数,第二个循环S[i] 表示i点是否满足条件 ,第三个循环S[i]计算前缀数组和 AC代码:
 #include <stdio.h>
#include <string.h> int s[];
int main ()
{
int n,k,i,q,x,y;
while (~scanf("%d%d%d",&n,&k,&q))
{
for (i = ; i < n; i ++)
{
scanf("%d%d",&x,&y);
s[x] ++; s[y+] --;
} for (i = ; i < ; i ++)
s[i] += s[i-]; // 将所有覆盖的位置的区间个数 打表
for (i = ; i < ; i ++)
s[i] = (s[i]>=k); // 大于k个的标记为1 否则为0
for (i = ; i < ; i ++)
s[i] += s[i-]; // 计算出前缀数组和
while (q --)
{
scanf("%d%d",&x,&y);
printf("%d\n",s[y]-s[x-]);
}
}
return ;
}

 

Codeforces Round #419 A+B的更多相关文章

  1. Codeforces Round #419 D. Karen and Test

    Karen has just arrived at school, and she has a math test today! The test is about basic addition an ...

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

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

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

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

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

  5. Codeforces Round #419 (Div. 2)

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

  6. codeforces round #419 E. Karen and Supermarket

    On the way home, Karen decided to stop by the supermarket to buy some groceries. She needs to buy a ...

  7. codeforces round #419 C. Karen and Game

    C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard i ...

  8. codeforces round #419 B. Karen and Coffee

    To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...

  9. codeforces round #419 A. Karen and Morning

    Karen is getting ready for a new school day! It is currently hh:mm, given in a 24-hour format. As yo ...

  10. Codeforces Round #419 Div. 1

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

随机推荐

  1. 配置 CentOS 7 安装位置

    红框里是CentOS 7安装程序检测到的硬盘,选择你想把系统安装到哪个硬盘当中. 点击 Add disk 按钮可以添加指定的附加设备或者网络设备(通过ISCSI.FCoE等方式添加硬盘) 此处设置分区 ...

  2. RestTemplate--解决中文乱码

    [原文链接]:https://www.tecchen.xyz/rest-template-messycode.html 我的个人博客:https://www.tecchen.xyz 在开发扇贝-每日一 ...

  3. JDK下载安装以及环境变量的配置

    JDK是Java Development Kit 的缩写,是 Java 语言的软件开发工具包,主要用于移动设备.嵌入式设备上的java应用程序. 一.JDK的下载 这里以Oracle官网下载为例 1. ...

  4. php 如何匹配中文或英文姓名

    这几天在做项目的用户注册时,想限制用户使用一些比较奇怪的字符作为名字,即使用中文或者英文名字. 查了一些资料,例如:网友挥得更高的百度空间 写下了以下函数. //验证名字和密码 if (!preg_m ...

  5. 聊一聊Iterable与Iterator的那些事!

    前言 欢迎关注公众号:Coder编程 获取最新原创技术文章和相关免费学习资料,随时随地学习技术知识! 在上一篇文章通过面试题,让我们来了解Collection,我们会发现Collection接口之上还 ...

  6. IDEA 启动项目,tomcat中配置的虚拟路径无法使用

    有时候,使用idea启动项目,非动静分离项目,直接根据图片url地址显示图片,会发现图片无法显示,tomcat中配置的虚拟路径无法使用,这时候需要配置idea.选择路径,然后给与一个访问名就行了.

  7. SQL语句映射文件(1)resultMap

    SQL 映射XML 文件是所有sql语句放置的地方.需要定义一个workspace,一般定义为对应的接口类的路径.写好SQL语句映射文件后,需要在MyBAtis配置文件mappers标签中引用,例如: ...

  8. 微软URLRewriter.dll的url重写的简单使用

    1.先下载MSDNURLRewriting.zip包,打开代码生成URLRewriter.dll文件: 2.将URLRewriter.dll文件引用到项目中: 3.在web.config文件中  &l ...

  9. ASP.NET Core 中的依赖注入

    目录 什么是依赖注入 ASP .NET Core 中使用依赖注入 注册 使用 释放 替换为其它的 Ioc 容器 参考 什么是依赖注入 软件设计原则中有一个依赖倒置原则(DIP),为了更好的解耦,讲究要 ...

  10. CSS- 文本超出指定宽度后隐藏并显示为省略号

    一般的文字截断(适用于内联与块): .text-overflow { display:block;/*内联对象需加*/ width:25em; word-break:keep-all;/* 不换行 * ...