Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<climits>
- #define cdbg cerr << "Debug in " << __func__ << ": "
- #define q << '\n'
- #define sp << ' '
- #define pb push_back
- #define mp make_pair
- #define ft first
- #define sd second
- #define sqr(x) x*x
- #define pqe priority_queue
- #define ld long double
- #define ll long long
- #define lll __int128
- #define ull unsigned long long
- #define pii pair<ll , ll>
- #define vi vector<int>
- using namespace std;
- ll n, m, k, mn = INT_MAX, a , b , c , d, goth, keks,ans;
- bool isProstoye(ll x)
- {
- bool f = 0;
- for (int i = 2; i*i <= x; i++)
- if (x % i == 0) {f = 1; break;}
- return !f;
- }
- pii arr[10000];
- vi v;
- main()
- {
- cin >> a >> b >> c >> d;
- goth = keks = (d-c)/2;
- if (c % 2 == 0 || d % 2 == 0) keks++;
- if (d % 2 == 1 || d % 2 == 1) goth++;
- for (int i = a; i <= b; i++)
- {
- if (i >= 2) ans += keks;
- if (i >= 2 && c <= 2) ans--;
- if (i >= 2) ans += goth;
- if (i >= 2 && c <= 5)
- {
- ans--;
- if (c <= 3) ans--;
- if (c == 1) ans--;
- }
- if (i == 1)
- {
- for (int j = c; j <= d; j++)
- {
- if (isProstoye(j)) ans++;
- }
- }
- }
- cout << ans;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement