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

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.

这场算是有史以来打的最烂的一场了。。。

开场刷进去 放眼望去全是水题 就傻不拉几的写了AB 交了以后wa了??!

附AC代码:

 #include<bits/stdc++.h>
using namespace std; int main(){
long long l1,r1,l2,r2,k;
cin>>l1>>r1>>l2>>r2>>k;
long long i=max(l1,l2);
long long j=min(r1,r2);
if(j>=i){
if(k<=j&&k>=i)cout<<j-i<<endl;
else cout<<j-i+<<endl;
}
else{
cout<<""<<endl;
}
return ;
}

最新文章

  1. 拉格朗日插值法——用Python进行数值计算
  2. centos5.11 repo 安装mysql5.7
  3. 写出易调试的SQL—西科软件
  4. 【转载】开发备必:WEB前端开发规范文档
  5. Oracle Rac crs无法启动
  6. SmartDraw2008破解过程总结
  7. Jackson工具
  8. PHP二维数组去重(指定键名)
  9. 【THUSC2017】【LOJ2979】换桌 线段树 网络流
  10. Java 基础 JRE和JDK的区别
  11. ECMA Script 6_数值的扩展
  12. Python全栈问答小技巧_2
  13. contenteditable=&quot;true&quot;让div可编辑
  14. Django入门(二)
  15. MIUI7,Android版本5.0.2,一个程序发送自定义广播,另一个程序没有接收到
  16. amazeui笔记-CSS 布局相关
  17. WPF ComboBox下拉绑定Treeview 功能的实现
  18. yii2.0发送qq邮件详情配置
  19. 【转载】CentOS7.0下安装Telnet
  20. Android 百度地图 简单实现--- 美食搜索

热门文章

  1. iOS 内存管理策略
  2. javaproject积累——树形结构的操作
  3. redux 及 相关插件 项目实战
  4. 基本SQL 语句操作数据增删查改
  5. CentOS 5.5下搭建部署独立SVN服务器全程详解
  6. HDU 1028 Ignatius and the Princess III (母函数或者dp,找规律,)
  7. 一道有关switch-case题目
  8. eclipse新建android项目出现非常多错误
  9. 关于UDID和UUID的区别
  10. 事件序列化器 Flume 的无数据丢失保证,Channel 和事务