Codeforces Round #371 (Div. 2) - A
题目链接:http://codeforces.com/contest/714/problem/A
题意:有两个人A,B 给定A的时间区间[L1,R1], B的时间区间[L2,R2],然后在正好K分钟的时候A小时一分钟,即K这一分钟A不在。现在问A和B在时间上能相遇多久。
思路:相遇的区间是[max(L1,L2),min(R1,R2)],然后判断K是否在这个区间里就好了。 还有可能相遇的区间大小为负数即A和B不相遇
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<time.h>
#include<cmath>
#include<stack>
using namespace std;
typedef long long int LL;
#include <cstdio>
const int MAX = + ;
int main(){
//#ifdef kirito
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//#endif
LL l1, l2, r1, r2, k;
while (~scanf("%I64d%I64d%I64d%I64d%I64d", &l1, &r1, &l2, &r2, &k)){
LL L = max(l1, l2);
LL R = min(r1, r2);
LL ans = R - L + ;
if (k >= L&&k <= R){
ans--;
}
if (ans < ){ ans = ; }
cout << ans << endl;
}
return ;
}
Codeforces Round #371 (Div. 2) - A的更多相关文章
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #371 (Div. 2)B. Filya and Homework
题目链接:http://codeforces.com/problemset/problem/714/B 题目大意: 第一行输入一个n,第二行输入n个数,求是否能找出一个数x,使得n个数中的部分数加上x ...
- Codeforces Round #371 (Div. 2) - B
题目链接:http://codeforces.com/contest/714/problem/B 题意:给定一个长度为N的初始序列,然后问是否能找到一个值x,然后使得序列的每个元素+x/-x/不变,最 ...
- 严格递增类的dp Codeforces Round #371 (Div. 1) C dp
http://codeforces.com/contest/713 题目大意:给你一个长度为n的数组,每次有+1和-1操作,在该操作下把该数组变成严格递增所需要的最小修改值是多少 思路:遇到这类题型, ...
- Codeforces Round #371 (Div. 2) C 大模拟
http://codeforces.com/contest/714/problem/C 题目大意:有t个询问,每个询问有三种操作 ①加入一个数值为a[i]的数字 ②消除一个数值为a[i]的数字 ③给一 ...
- Codeforces Round #371 (Div. 1) C. Sonya and Problem Wihtout a Legend 贪心
C. Sonya and Problem Wihtout a Legend 题目连接: http://codeforces.com/contest/713/problem/C Description ...
- Codeforces Round #371 (Div. 1) D. Animals and Puzzle 二维倍增
D. Animals and Puzzle 题目连接: http://codeforces.com/contest/713/problem/D Description Owl Sonya gave a ...
- Codeforces Round #371 (Div. 2) C. Sonya and Queries 水题
C. Sonya and Queries 题目连接: http://codeforces.com/contest/714/problem/C Description Today Sonya learn ...
- Codeforces Round #371 (Div. 2) D. Searching Rectangles 交互题 二分
D. Searching Rectangles 题目连接: http://codeforces.com/contest/714/problem/D Description Filya just lea ...
随机推荐
- linux 用户、用户组不能是全数字
今天封装命令行,需要创建用户.用户组,遇到下面问题,如图: 当时我和迷茫,为什么明明存在‘1111’这个用户组,但是却提示不存在呢??难道是linux的一个bug??? 接着我又试了几个: 发现规律了 ...
- sqlserver 数据库中时间函数的建立
create function [dbo].[HtoSec](@lvalue as int)RETURNS intBEGINDECLARE @temp intSet @temp = @lvalue * ...
- September 17th 2016 Week 38th Saturday
Our eyes do not show a lack of beauty, but a lack of observation. 世上不是缺少美,而是缺少发现美的眼睛. Don't pay too ...
- xth的旅行(codevs 1450)
题目描述 Description 毕业了,Xth很高兴,因为他要和他的 rabbit 去双人旅行了.他们来到了水城威尼斯.众所周知(⊙﹏⊙b汗),这里的水路交通很发达,所以 xth 和 rabbit ...
- TCP/IP五层模型
(2)TCP/IP五层模型的协议 应用层 传输层 网络层 数据链路层 物理层 物理层:中继器.集线器.还有我们通常说的双绞线也工作在物理层 数据链路层:网桥(现已很少使用).以太网交换机(二层 ...
- poj2912(种类并查集+枚举)
题目:http://poj.org/problem?id=2912 题意:n个人进行m轮剪刀石头布游戏(0<n<=500,0<=m<=2000),接下来m行形如x, y, ch ...
- hadoop 2.5 hdfs namenode –format 出错Usage: java NameNode [-backup] |
在 cd /home/hadoop/hadoop-2.5.2/bin 下 执行的./hdfs namenode -format 报错[hadoop@node1 bin]$ ./hdfs nameno ...
- php 审核管理
权限管理界面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. ...
- git 提交代码的流程
[root@ok-T IT-DOC]# ls hx-海星-wifi.rd web收藏.txt [root@ok-T IT-DOC]# git status -s ?? "web\346\22 ...
- html+css学习笔记:实用LessColor函数搭建配色方案
http://www.zcool.com.cn/article/ZMTUyNDc2.html 前言:用LESS CSS框架进行编码会简化代码结构,提高我们的工作效率,但是试验后你会发现,默认情况下,L ...