Codeforces Round #371 (Div. 2) A

Posted %%%%%

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #371 (Div. 2) A相关的知识,希望对你有一定的参考价值。

传送门

题意: 

思路:

AC代码:

 

 1 #include "iostream"
 2 #include "string.h"
 3 #include "stack"
 4 #include "queue"
 5 #include "map"
 6 #include "algorithm"
 7 #include "stdio.h"
 8 #include "math.h"
 9 #define ll long long
10 #define mem(a) memset(a,0,sizeof(a))
11 #define max(a,b) a > b ? a : b
12 #define min(a,b) a < b ? a : b
13 
14 using namespace std;
15 
16 int main()
17 {
18     ll l1,l2,r1,r2,k,l,r,ans = 0;
19     cin>>l1>>r1>>l2>>r2>>k;
20     l = max(l1,l2);
21     r = min(r1,r2);
22     ans += r-l+1;
23     if(k>=l && k<=r)
24         ans--;
25     if(r<l)
26         ans = 0;
27     printf("%I64d\n",ans);
28    return 0;
29 }

 

以上是关于Codeforces Round #371 (Div. 2) A的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #371 (Div. 1) D. Animals and Puzzle 二维倍增

Codeforces Round #371 (Div. 1)

Codeforces Round #371 (Div. 2) B

Codeforces Round #371 (Div. 2)B. Filya and Homework

Codeforces Round #371 (Div. 1) D - Animals and Puzzle 二维ST表 + 二分

Codeforces Round #371 (Div. 2) C. Sonya and Queries(字典树)