Codeforces 714A 朋友聚会
参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6395268.html
Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old friend Sonya!
Sonya is an owl and she sleeps during the day and stay awake from minute l1 to minute r1 inclusive. Also, during the minute k she prinks and is unavailable for Filya.
Filya works a lot and he plans to visit Sonya from minute l2 to minute r2 inclusive.
Calculate the number of minutes they will be able to spend together.
The only line of the input contains integers l1, r1, l2, r2 and k (1 ≤ l1, r1, l2, r2, k ≤ 1018, l1 ≤ r1, l2 ≤ r2), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks.
Print one integer — the number of minutes Sonya and Filya will be able to spend together.
1 10 9 20 1
2
1 100 50 200 75
50
In the first sample, they will be together during minutes 9 and 10.
In the second sample, they will be together from minute 50 to minute 74 and from minute 76 to minute 100.
解法
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
ll l1,l2,r1,r2,k;
while(cin>>l1>>r1>>l2>>r2>>k){
ll min = min(r1,r2);
ll max = max(l1,l2);
ll ans = min-max+;
if(max > min){
cout<<<<endl;
continue;
}
if(k >= max && k <= min)
ans--;
cout<<ans<<endl;
}
return ;
}
Codeforces 714A 朋友聚会的更多相关文章
- Codeforces 714A Meeting of Old Friends
A. Meeting of Old Friends time limit per test:1 second memory limit per test:256 megabytes input:sta ...
- 朋友聚会,下馆子要到哪家饭馆?——单样本T检验帮你找到答案
聚会时,五花八门的饭馆让人眼花缭乱,应该到哪家店吃呢?除了美味的食物,良好的服务态度也是好饭馆的必备品质,如何判断一家饭馆的服务态度如何?此时可以用单样本T检验来找答案~ 让顾客对A饭馆的服务态度 ...
- CodeForces 714A
Description Today an outstanding event is going to happen in the forest — hedgehog Filya will come t ...
- IT人士怎样的休息方式才高效
为什么你睡了11个小时仍然觉得疲累? 为什么你花了好几万去岛国度假并没有增加生活的热情? 都说要去KTV,去夜店,去游乐园就能忘掉不快,更带劲地开始新的一天,但是尽兴归来心里只剩空虚? 我们真的明白休 ...
- durex-word
"(半夜没睡着) “你是不是饿了,哎呀我也饿了.”" "(聊到合拍处) “我和你有一万句me too想要说.”" "(异地恋) “我辞职,去你那儿吧! ...
- IT 外包中的甲方乙方,德国人,美国人,印度人和日本人印象杂谈
开篇介绍 最近经常和朋友聚会,三十而立的年龄自然讨论最多的就是各自的小家庭,如何赚钱,工作,未来的就业发展,职业转型等话题.还有各种跳槽,机会选择,甲方乙方以及外包中的各种趣事,外企与国内私企的发展机 ...
- <转>好婚姻是彼此放心
-01- 临下班,马丽听到隔壁桌的方雅在打电话,声音听起来嗲声嗲气:“有个朋友晚上约我吃饭,要晚点回来,你不用等我了哦.” 电话挂断时,已经到了下班的点.方雅扭头对马丽说:“丽姐,待会我们一起去吃个饭 ...
- 【原创】我是怎么从零开始教女同学进行php开发的(4)
周末给自己放了一个小假,周五晚上跟同学出去吃饭,周六又休息了一天,直到周日才坐到电脑前面码字. 本来说好周末这两天把之前三篇的代码根据评论中的建议好好修改一下的,顺便认真系统地学习一遍HTML基础.结 ...
- PHP常用函数备用
刚学习php的时候,我也为记忆php函数苦恼不已.认为干嘛记忆这么枯燥无味的东西呢?用的时候查一下手册不就行了吗?但是当时因为身在辅导机构,还是记忆了一大堆自己并不感兴趣的函数. 由此就想起来,小的时 ...
随机推荐
- 面试 6:拓展性更好的代码,更容易拿到 Offer
今天给大家带来的是 <剑指 Offer>习题:调整数组顺序使奇数位于偶数前面,纯 Java 实现希望大家多加思考. 面试题:输入一个整型数组,实现一个函数来调整该数组中的数字的顺序,使 ...
- 固态硬盘的PCIE,SATA,M2,NVMe,AHCI分别都指什么?别再搞混了
原文:https://baijiahao.baidu.com/s?id=1616207956596122967&wfr=spider&for=pc 科技娱乐屋 18-11-0420:5 ...
- H5 61-浮动元素贴靠现象
61-浮动元素贴靠现象 <!DOCTYPE html><html lang="en"><head> <meta charset=" ...
- H5 58-网页的布局方式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Python学习第三篇——访问列表部分元素
dongman =["huoying","sishen","si wang bi ji","pan ni de lu lu xiu ...
- PS电商产品banner设计
- java中流的简单小结
1.分类 按字节流分: InputStream(输出流) OutputStream(输入流) 按字符流分: Reader Writer 提示:输入.输出是站在程序的角度而言,所有输入流是“读 ...
- 并发包学习之-atomic包
一,模拟并发代码: 线程不安全的代码 //并发模拟代码 public class CountExample { //请求总数 public static int clientTotal = 5000; ...
- git rebase的用法
改变基 一个git库,开发人员在master分支的Bcommit的时候,创建了一个dev分支,此时Bcommit是dev分支的基,然后分别进行两个分支的开发. 进行到master提交了Dcommit, ...
- 解决ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
解决办法: