参考自: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. 使用 OpenSSL 创建私有 CA:3 用户证书

    OpenSSL 创建私有 CA 三部曲:使用 OpenSSL 创建私有 CA:1 根证书使用 OpenSSL 创建私有 CA:2 中间证书使用 OpenSSL 创建私有 CA:3 用户证书 在前文&l ...

  2. C#代码中插入X86汇编

    这两天在看C# SIMD相关的东西, 在爆栈上面搜到一段代码, 表示很震惊, 还是得贴出来… [UnmanagedFunctionPointer(CallingConvention.StdCall)] ...

  3. H5 22-通配符选择器

    22-通配符选择器 我是标题 我是段落 我是超链接 --> 我是标题 我是段落 我是超链接 <!DOCTYPE html> <html lang="en"& ...

  4. 如何在Anaconda中把python环境更新更高版本

    把Anaconda中的python从3.5.5更新到3.6版本,不想卸载重新安装.办法如下: 开始->Anaconda Promot 在Anaconda Promot中,输入: conda up ...

  5. Python迭代器与格式化

    三元运算 对if-else判断的简写 >>> age = 18 >>> res = "You are so young!" if age < ...

  6. mysql数据库和JDBC学习

    数据库概念: 数据库(Database)是按照数据结构来组织.存储和管理数据的建立在计算机存储设备上的仓库. ---------数据库服务器,mysql(管理) 数据库服务器---->N多库-- ...

  7. PAT L2-016 愿天下有情人都是失散多年的兄妹

    https://pintia.cn/problem-sets/994805046380707840/problems/994805061769609216 呵呵.大家都知道五服以内不得通婚,即两个人最 ...

  8. 剑指offer(13)

    题目: 输入两棵二叉树A,B,判断B是不是A的子结构.(ps:我们约定空树不是任意一个树的子结构) 思路: 判断当前两个根结点是否相等,如果相等,判断左右子树是否相等,如果不依次判断左右子树是否满足上 ...

  9. drf信号量

    Django信号量回顾及drf信号量常用操作 一.在写接口视图时,保存/删除/更新数据前后需要对序列化后的数据进行处理的方法: 1.重写mixins.CreateModelMixin中恩的create ...

  10. 使用php导出excel并使用excel的求和统计函数对excel进行汇总

    1. 使用excel的统计函数对excel进行多条件汇总求和: =SUMIFS($D$:$D$, $A$:$A$, :$B$, :$C$, "三级片") 例如: =SUMIFS(求 ...