参考自: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. Vue常规后台系统,路由懒加载实现基于菜单数据并解耦

    路由依赖菜单 场景:文件名与路由组件名完全一致(随便大小写均可) 菜单使用一套,路由又存在一套,这样就很不舒服,于是做了如下处理: 尝试不用懒加载发现有难度,使用懒加载就很轻松了 data.js ex ...

  2. Spring+SpringMVC+MyBatis+easyUI整合基础篇(一)项目简述及技术选型介绍

    作者:13GitHub:https://github.com/ZHENFENG13版权声明:本文为原创文章,未经允许不得转载. 萌芽阶段 很久之前就开始打算整理一下自己的技术博客了,由于各种原因(借口 ...

  3. make太慢了,加快编译速度的方法 make -j

    make -j 既然IO不是瓶颈,那CPU就应该是一个影响编译速度的重要因素了. 用make -j带一个参数,可以把项目在进行并行编译,比如在一台双核的机器上,完全可以用make -j4,让make最 ...

  4. Echatrs 中PIE饼图中间位置怎么显示总数值?

    title: { text: '总资产', subtext: '2000000.00', x: 'center', y: 'center' }图例:

  5. Python之操作Excel

    使用之前先导入三个模块: import xlwt #只能写Excel import xlrd #只能读Excel import xlutils #修改Excel,在原来的基础上修改 一.写EXCEL ...

  6. CodeIgniter框架中尝试使用swoole

    ci框架版本:3.1.7.     swoole版本:1.7.      php版本:5.6 相关文档: 以cli方式运行ci框架 swoole官方手册 创建一个TestSwoole和Hello控制器 ...

  7. CentOS的el5, el6, el7代表什么

    https://www.cnblogs.com/EasonJim/p/9051851.html el: enterprise linux?

  8. js文字从左边飞入效果

    贴代码之前,我们先讲一下它的原理,我们使用setInterval,让文字一开始置于屏幕看不到的位置,左右上下都可以,然后让它的位置不断移入到屏幕看得到的位置. 下面上代码: html: <h2 ...

  9. WebSocket推送

    本篇博客只是记录websocket在自己的项目中的应用,只是记录,不做说明(后来替换为GoEasy了). /** * 握手的设置,这其实是为了获取session */ public class Get ...

  10. 下拉框插件select2的使用

    它的优点有: 样式还算好看,支持多选,支持索搜 下面来介绍下select2的用法 1.最简单的用法 只需要加载css和js即可使用 <select name="" id=&q ...