参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6395268.html

A. Meeting of Old Friends
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

  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.

Input

  The only line of the input contains integers l1r1l2r2 and k (1 ≤ l1, r1, l2, r2, k ≤ 1018l1 ≤ r1l2 ≤ r2), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks.

Output

  Print one integer — the number of minutes Sonya and Filya will be able to spend together.

Examples
  Input
  1 10 9 20 1

  Output
  2
  Input
  1 100 50 200 75
  Output
  50
Note

  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 朋友聚会的更多相关文章

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

  2. 朋友聚会,下馆子要到哪家饭馆?——单样本T检验帮你找到答案

      聚会时,五花八门的饭馆让人眼花缭乱,应该到哪家店吃呢?除了美味的食物,良好的服务态度也是好饭馆的必备品质,如何判断一家饭馆的服务态度如何?此时可以用单样本T检验来找答案~ 让顾客对A饭馆的服务态度 ...

  3. CodeForces 714A

    Description Today an outstanding event is going to happen in the forest — hedgehog Filya will come t ...

  4. IT人士怎样的休息方式才高效

    为什么你睡了11个小时仍然觉得疲累? 为什么你花了好几万去岛国度假并没有增加生活的热情? 都说要去KTV,去夜店,去游乐园就能忘掉不快,更带劲地开始新的一天,但是尽兴归来心里只剩空虚? 我们真的明白休 ...

  5. durex-word

    "(半夜没睡着) “你是不是饿了,哎呀我也饿了.”" "(聊到合拍处) “我和你有一万句me too想要说.”" "(异地恋) “我辞职,去你那儿吧! ...

  6. IT 外包中的甲方乙方,德国人,美国人,印度人和日本人印象杂谈

    开篇介绍 最近经常和朋友聚会,三十而立的年龄自然讨论最多的就是各自的小家庭,如何赚钱,工作,未来的就业发展,职业转型等话题.还有各种跳槽,机会选择,甲方乙方以及外包中的各种趣事,外企与国内私企的发展机 ...

  7. <转>好婚姻是彼此放心

    -01- 临下班,马丽听到隔壁桌的方雅在打电话,声音听起来嗲声嗲气:“有个朋友晚上约我吃饭,要晚点回来,你不用等我了哦.” 电话挂断时,已经到了下班的点.方雅扭头对马丽说:“丽姐,待会我们一起去吃个饭 ...

  8. 【原创】我是怎么从零开始教女同学进行php开发的(4)

    周末给自己放了一个小假,周五晚上跟同学出去吃饭,周六又休息了一天,直到周日才坐到电脑前面码字. 本来说好周末这两天把之前三篇的代码根据评论中的建议好好修改一下的,顺便认真系统地学习一遍HTML基础.结 ...

  9. PHP常用函数备用

    刚学习php的时候,我也为记忆php函数苦恼不已.认为干嘛记忆这么枯燥无味的东西呢?用的时候查一下手册不就行了吗?但是当时因为身在辅导机构,还是记忆了一大堆自己并不感兴趣的函数. 由此就想起来,小的时 ...

随机推荐

  1. Asp.Net Core实战(干货)

    序言 使用.NET Core,团队可以更容易专注的在.net core上工作.比如核心类库(如System.Collections)的更改仍然需要与.NET Framework相同的活力,但是ASP. ...

  2. Python Revisited Day 01

    逻辑操作符 身份操作符 is a = ['AAA', 3, None] b = ['AAA', 3, None] a is b #False b = a a is b #True 身份比较速度快,原因 ...

  3. Rikka with Subset HDU - 6092 (DP+组合数)

    As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some mat ...

  4. web网站css,js更新后客户浏览器缓存问题,需要刷新才能正常展示的解决办法

    问题描述 最近将公司官网样式进行了调整,部署到服务器后访问发现页面展示不正常,但是刷新之后就会展示正常. 问题分析 研究之后发现可能的原因有 css文件过大,加载缓慢 本地缓存问题,虽然服务器修改了c ...

  5. jupyter使用

    jupyter使用 安装 在anaconda3的安装路径中,尽量避免使用汉字或者括号. 启动 在Windows上正确安装Anaconda3,确认配置好环境变量,然后再命令行中输入jupyter not ...

  6. Python_数据类型的补充、集合set、深浅copy

    1.数据类型的补充 1.1 元组 当元组里面只有一个元素且没有逗号时,则该数据的数据类型与括号里面的元素相同. tu1 = ('laonanhai') tu2 = ('laonanhai') prin ...

  7. node笔记

    基础入门可参考: <一起学 Node.js>—— https://github.com/nswbmw/N-blog 核心模块使用前需要引入   let fs=require('fs'); ...

  8. java对象的四种引用:强引用、软引用、弱引用和虚引用

    在JDK1.2之前,创建的对象只有在处于可触及(reachable)的状态下,才能被程序使用.也就是说,若一个对象不被任何变量引用,那么程序就无法再使用这个对象.垃圾回收器一旦发现这些无用对象,就会对 ...

  9. Azure系列2.1.1 —— BlobContainerPermissions

    (小弟自学Azure,文中有不正确之处,请路过各位大神指正.) 网上azure的资料较少,尤其是API,全是英文的,中文资料更是少之又少.这次由于公司项目需要使用Azure,所以对Azure的一些学习 ...

  10. [转帖]TCP和UDP的135、137、138、139、445端口的作用

    TCP和UDP的135.137.138.139.445端口的作用 https://www.cnblogs.com/IvanChen/p/4500698.html 竟然不知道 端口具体是干什么的.. 如 ...