A. Meeting of Old Friends
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
InputThe 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.
OutputPrint one integer — the number of minutes Sonya and Filya will be able to spend together.
Examplesinput1 10 9 20 1output2input1 100 50 200 75output50NoteIn 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 ;
}
最新文章
- 拉格朗日插值法——用Python进行数值计算
- centos5.11 repo 安装mysql5.7
- 写出易调试的SQL—西科软件
- 【转载】开发备必:WEB前端开发规范文档
- Oracle Rac crs无法启动
- SmartDraw2008破解过程总结
- Jackson工具
- PHP二维数组去重(指定键名)
- 【THUSC2017】【LOJ2979】换桌 线段树 网络流
- Java 基础 JRE和JDK的区别
- ECMA Script 6_数值的扩展
- Python全栈问答小技巧_2
- contenteditable=";true";让div可编辑
- Django入门(二)
- MIUI7,Android版本5.0.2,一个程序发送自定义广播,另一个程序没有接收到
- amazeui笔记-CSS 布局相关
- WPF ComboBox下拉绑定Treeview 功能的实现
- yii2.0发送qq邮件详情配置
- 【转载】CentOS7.0下安装Telnet
- Android 百度地图 简单实现--- 美食搜索