Codeforces_714_A

http://codeforces.com/problemset/problem/714/A

 

水,注意K的值。

 

#include <iostream>
using namespace std;

int main()
{
    long long a,b,c,d,k,left,right,sum = 0;
    cin >> a >> b >> c >> d >> k;
    if(a <= c && c <= b && b <= d)
    {
        left = c;
        right = b;
        sum = b-c+1;
    }
    else if(a <= c && d <= b)
    {
        left = c;
        right = d;
        sum = d-c+1;
    }
    else if(c <= a && a <= d && d <= b)
    {
        left = a;
        right = d;
        sum = d-a+1;
    }
    else if(c <= a && b <= d)
    {
        left = a;
        right = b;
        sum = b-a+1;
    }
    if(sum && left <= k && k <= right)  sum--;
    cout << sum << endl;
    return 0;
}

 

posted @ 2016-09-14 12:43  zzzzzzzzhu  阅读(200)  评论(0编辑  收藏  举报