Submission
Status:
PPPPPPPPPP
Score: 100
User: Nathlol2
Problemset: สามสหาย
Language: cpp
Time: 0.011 second
Submitted On: 2025-05-09 15:27:09
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ar array
#define pii pair<int, int>
#define pll pair<ll, int>
#define fi first
#define sc second
#define INF (ll)1e18
#define MOD (ll)1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define vt vector
#define pb push_back
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sz(x) (int)(x).size()
#define F_OR(i, a, b, s) for (int i = (a); (s) > 0 ? i < (b) : i > (b); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define rep(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define each(x, a) for (auto& x : a)
template <class T>
bool umin(T& a, const T& b) {
return b < a ? a = b, 1 : 0;
}
template <class T>
bool umax(T& a, const T& b) {
return a < b ? a = b, 1 : 0;
}
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
const int dxx[8] = {0, 0, 1, 1, 1, -1, -1, -1}, dyy[8] = {1, -1, 0, -1, 1, 0, -1, 1};
const int mxN = 5003;
void solve(){
//sieve
vt<bool> isp(mxN * 3, true);
isp[0] = isp[1] = 0;
rep(i, 2, mxN * 3){
if(isp[i]){
rep(j, i + i, mxN * 3, i){
isp[j] = 0;
}
}
}
vt<int> p;
rep(i, 2, mxN * 3){
if(isp[i]){
p.pb(i);
}
}
ll ans = 0;
int l, r;
cin >> l >> r;
each(x, p){
if(x * 3 < l || r * 3 < x){
continue;
}
rep(i, l, r + 1){
if(i * 3 > x){
continue;
}
ll need = x - i;
ll a = (need / 2) - i + 1;
ll b = r - ((need + 1) / 2) + 1;
ans += max(min(a, b), 0LL);
}
}
cout << ans << '\n';
}
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(0);
int tc = 1;
//cin >> tc;
while(tc--){
solve();
}
}