首页 > 代码库 > Codeforces Round #371 (Div. 2) A

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 long10 #define mem(a) memset(a,0,sizeof(a))11 #define max(a,b) a > b ? a : b12 #define min(a,b) a < b ? a : b13 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