-
Notifications
You must be signed in to change notification settings - Fork 0
/
paint.cpp
72 lines (65 loc) · 1.42 KB
/
paint.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define clr(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for (int i = a; i < b; i++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(x) ((x) < 0 ? -(x) : (x))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using pii = pair<int, int>;
using pll = pair<long, long>;
const ll mod = 1000000007;
template <class T>
T gcd(T a, T b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) { return (a * b) / gcd(a, b); }
template <class T>
string converter(T n)
{
stringstream x;
x << n;
return x.str();
}
//void swapi(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}
//void swaps (char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
/*
adnaneaabbar
*/
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("paint.in", "r", stdin);
freopen("paint.out", "w", stdout);
int a, b, c, d, ans = 0;
cin >> a >> b >> c >> d;
int m = min(a, c);
int mm = max(b, d);
rep(i, m, mm + 1)
{
if (i >= a && i < b)
{
ans++;
}
else if (i >= c && i < d)
{
ans++;
}
}
cout << ans;
return 0;
}