text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 9; int main() { long long i, j, m, n, t, l, r, fir, sec; scanf("%lld", &t); while (t--) { scanf("%lld %lld %lld", &n, &l, &r); long long pos = 0; for (i = 1; i <= n; i++) { if (i == n) { pos = -1; break; }...
#include <bits/stdc++.h> #pragma GCC optimize "trapv" const int inf1 = 1e9; const long long int inf2 = 1e18; const int N = 100000; using namespace std; int dirs[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; int solve() { long long int n, l, r; cin >> n >> l >> r; if (l == n * (n - 1) + 1) { cout << 1 << "\n"; ...
#include <bits/stdc++.h> using namespace std; const long long N = 200001; const long long MOD = 1000000007; const long long INF = LLONG_MAX; vector<long long> v; void pre() { v.push_back(1LL); for (long long i = 1; i <= 1e5; i++) v.push_back(i * 2); for (long long i = 1; i < v.size(); i++) v[i] += v[i - 1]; } lon...
#include <bits/stdc++.h> using namespace std; long long t, n, l, r, q; int main() { scanf("%lld", &t); while (t--) { scanf("%lld%lld%lld", &n, &l, &r); long long now = 0; q = n - 1; bool flag = 0; for (int i = 1; i < n - 1; i++) { if (now + (n - i) * 2 >= l) { q = i; break;...
#include <bits/stdc++.h> using namespace std; long long cnt[100006]; vector<int> ans; int main() { int tests = 1; int n; long long l, r; scanf("%d", &tests); while (tests--) { ans.clear(); scanf("%d%lld%lld", &n, &l, &r); for (int i = 1; i < n; ++i) cnt[i] = 1ll * (2 * n - i - 1) * i; int s = ...
#include <bits/stdc++.h> #pragma gcc optimize("O3") #pragma gcc optimize("Ofast") using namespace std; long long n, l, r; long long i, j, t; void nx() { j++; if (j == n + 1) { i++; j = i + 1; } } void print() { if (!t) { cout << i << " "; } else { cout << j << " "; nx(); } t ^= 1; } in...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, lgrp = 0, rgrp = 0; long long int l, r; cin >> n >> l >> r; for (int k = 1; k <= n - 1; ++k) { if (l <= 2 * (n - k) * 1LL) { lgrp =...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; using vi = vector<ll>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t; cin >> t; while (t--) { ll n, l, r; cin >> n >> l >> r; ll sm = 0; ll iters = 0; ll add = n - 1; if (...
#include <bits/stdc++.h> using namespace std; long long v[100010]; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { long long n, l, r; cin >> n >> l >> r; for (int i = 1; i < n; ++i) v[i] = 2 * (n - i); v[n] = 1; for (int i = 1; i <= n; ++i) v[i] += v[i ...
#include <bits/stdc++.h> using namespace std; void solve() { long long n, l, r; cin >> n >> l >> r; long long printed = 0; long long num = 0; while (printed < l) { num++; printed += (2 * (n - num)); if (num == n - 1) { break; } } printed -= 2 * (n - num); num--; vector<int> nums;...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long q, n, i, j, sum, sum2, l, r, pos; cin >> q; while (q--) { cin >> n >> l >> r; sum = 1; for (i = 1; i <= n; i++) { sum2 = max((n - 1 - i), 0 * 1LL) + (n - i) + 1; if (sum + sum2 >= l) { ...
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 100; const long long mod = 1e9 + 7; const long long inf = 1e18; long long q, n, l, r, s, t; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; cin >> q; while (q--) { cin >> n >> l >> r; s = 0; t = 1; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); size_t T; cin >> T; while (T--) { long long int n, l, r; cin >> n >> l >> r; long long int t = 1; long long int k = 1; while (k < l && t != n) { k += 2 * (n - t++); } if (k > l) { k -...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; using ll = long long; long long arr[N]; ll n; int solve(ll x) { if (x == n * (n - 1) + 1) { return 1; } auto p = lower_bound(arr + 1, arr + n + 1, x) - arr - 1; x -= arr[p]; if (x & 1) { return p + 1; } return (p + 1 + x / 2); }...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; for (int i = (0); i < (t); i += 1) { long long n, l, r; cin >> n >> l >> r; bool z = false; if (r == n * (n - 1) + 1) { r--; z = true; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int t; ll n, st, dr; cin >> t; while (t--) { cin >> n >> st >> dr; int deAfisat = 0; if (dr == n * (n - 1) + 1) { deAfisat = 1; dr--; } if (st == 1 && dr == 1) { cout << 1 << '\n'; contin...
#include <bits/stdc++.h> using ll = long long; using namespace std; const ll N = 2e5 + 5, mod = 1e9 + 7; const ll inf = 1e18; struct cmp { bool operator()(pair<int, int> a, pair<int, int> b) { if (a.first == b.first) return a.second < b.second; return a.first > b.first; } }; ll power(ll x, ll p) { ll r = ...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e13 + 5; const int mod = 1e9 + 7; const int maxn = 1e5 + 5; long long n, l, r, s[maxn]; int calc(long long x) { if (x > s[n - 1]) return 1; long long a = lower_bound(s + 1, s + n, x) - s; long long b = x - s[a - 1]; if (b % 2) return a; ...
#include <bits/stdc++.h> using namespace std; long long a[1000006]; long long n; map<long long, long long> mp; int main() { long long Q; cin >> Q; while (Q--) { cin >> n; long long l, r; cin >> l >> r; a[0] = (n - 1) * 2; long long k = a[0] - 2; long long po = 0; for (int i = 1; i < 10...
#include <bits/stdc++.h> using namespace std; long long f(long long N, long long x) { return (2 * N - 1 - x) * x; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t; cin >> t; while (t--) { long long N; cin >> N; long long l, r; cin >> l >> r; long long ng = 0, ok = N; while...
#include <bits/stdc++.h> #pragma GCC optimize("O3", "unroll-all-loops") using namespace std; ifstream in; ofstream out; const long long kk = 1000; const long long ml = kk * kk; const long long mod = ml * kk + 7; const long long inf = ml * ml * ml + 7; long long n, l, r; bool viv = false; vector<long long> v; void solve...
#include <bits/stdc++.h> #pragma GCC optimize("-O3") using namespace std; const double PI = acos(-1); long long gcd() { return 0ll; } template <typename T, typename... Args> T gcd(T a, Args... args) { return __gcd(a, (__typeof(a))gcd(args...)); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cou...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long T; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> T; while (T--) { long long n, l, r; cin >> n >> l >> r; long long g = n * (n - 1) + ...
#include <bits/stdc++.h> using namespace std; template <typename T> T InvMod(T a, T b, T &x, T &y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = InvMod(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; } long long fact(long long n) { if (n == 1) return 1; return (n % ...
#include <bits/stdc++.h> const long long int maxn = 1e10; const long long mod = 1e9 + 7; using namespace std; long long int power(long long int a, long long int b) { long long int res = 1; while (b > 0) { if (b % 2 == 1) res = res * a; a = a * a; b = b / 2; } return res; } long long po(long long x, ...
#include <bits/stdc++.h> using namespace std; const int mn = 1 * (int)(1e5) + 10; const int mod = 1 * (int)(1e9) + 7; const int mm = 1 * (int)(1e3) + 10; const int base = 1 * (int)(1e9); const bool aNs = 0; int tt, ntest = 1; void docfile() { ios::sync_with_stdio(false); cin.tie(nullptr); if (ifstream("test.inp")...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); srand(time(NULL)); ; long long int p; cin >> p; while (p--) { long long int a, b, c, d, e, l, r, f, cnt = 1; vector<long long int> Ans; cin >> a >> l >> r; f = l; long lo...
#include <bits/stdc++.h> using namespace std; long long n, l, r; long long num; vector<long long> ans; bool intersect(long long l1, long long r1, long long l2, long long r2) { return min(r1, r2) >= max(l1, l2); } void cal(long long left) { if (left == n) return; if (intersect(l, r, num + 1, num + 2 * (n - left)))...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; for (int t = 0; t < T; ++t) { long long n, l, r; cin >> n; cin >> l; cin >> r; long long curr_position = 0; for (long long i1 = 1; i1 < n; ++i1) { long long x = cu...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") int T; int n, L; long long l, r; vector<int> v = {1, 2, 1}; long long cyc(int x) { if (x == n - 1) return 3; long long res = 2 * (n - x); return res; } void printcyc(int nr, long long start, int len) { if (nr == n - 1) { int step = ...
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve() { long long n, l, r; cin >> n >> l >> r; long long rngIdx = 0; long long begin = 0, end = n; while (begin < end) { long long mid = begin + (end - begin) / 2; if (2 * n * mid - mid * (mid + 1) >= l) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pr = pair<int, int>; template <typename T> void _read(T *arr, int n) { for (int i = 0; i < n; i++) cin >> arr[i]; } template <typename T> void _write(T *arr, int n) { for (int i = 0; i < n; i++) cout << arr[i] << " "; ...
#include <bits/stdc++.h> using namespace std; long long n, l, r; void solve(long long l, long long r) { long long s = 1; while (s <= n && l > 2 * (n - s)) { l -= 2 * (n - s); r -= 2 * (n - s); s++; } long long cnt = l / 2 + l % 2; cnt += s; while (s <= n && l <= r) { while (cnt <= n) { ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(); int T; cin >> T; while (T--) { long long n, l, r; cin >> n >> l >> r; long long e = 0, s = -1, f = -1; for (long long i = 1; i < n; i++) { e += 2 * (n - i); if (e >= l) { s = i; ...
#include <bits/stdc++.h> template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(fals...
#include <bits/stdc++.h> using namespace std; int t, n, s, lc; long long l, r, k; inline long long read() { long long ans = 0; char c = getchar(); while (c < 48 || c > 57) c = getchar(); while (c >= 48 && c <= 57) ans = (ans << 3) + (ans << 1) + (c ^ 48), c = getchar(); return ans; } inline void write(int...
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long t; cin >> t; while (t--) { long long n, l, r; cin >> n >> l >> r; vector<long long> lol = {0}; for (long long i = n - 1; i >= 1; i--) { lol.push_bac...
#include <bits/stdc++.h> using namespace std; int cas, z, x, w, h, a[500000]; long long n, m; int main() { scanf("%d", &cas); while (cas--) { scanf("%d%lld%lld", &z, &n, &m); x = 1; while (n > (z - x) * 2) { if (x == z) { m = 0; printf("1"); break; } n -= (z - x...
#include <bits/stdc++.h> using namespace ::std; const long double PI = acos(-1); const long long MOD = 1000000000 + 7; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long add(long long a, long long b, long long m = MOD) { if (a >= m) a %= m; if (b >= m) b %= m; if (a < 0) a +=...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; long long cur = 0; while (t--) { cur = 0; long long n, l, r; cin >> n >> l >> r; for (int i = 1; i <= n; i++) { if (cur + 2 * (n - i) < l) cur += 2 * (n - i); else { while (l <= r && i <...
#include <bits/stdc++.h> using namespace std; int T; int n; long long l, r; void out(long long sum, int now, int num, long long i) { if (now == n) { if (i != l) printf(" "); printf("1"); return; } for (i; i <= min(sum + num - 1, r); i++) { int N; if ((i - sum + 1) % 2) N = now; else ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n, l, r; cin >> n >> l >> r; long long int sum = 0; long long int start = 1; int done = 0; while (sum < l) { sum += 2 * (n - start); start++; if (start > n) { c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); size_t T; cin >> T; while (T--) { long long int n, l, r; cin >> n >> l >> r; long long int t = 1; long long int k = 1; while (k < l && t != n) { k += 2 * (n - t++); } if (k > l) { k -...
#include <bits/stdc++.h> using namespace std; void yes() { cout << "YES" << endl; } void no() { cout << "NO" << endl; } void solve(int qq) { long long n; cin >> n; long long l, r; cin >> l >> r; long long cnt = 0; long long odd = 0; long long start = 0; if (l == n * (n - 1) + 1) { cout << 1 << endl;...
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; for (int tc = 0; tc < (t); tc += 1) { long long n, l, r; cin >> n >> l >> r; l--; bool last1 = false; if (r == n * (n - 1) + 1) { last1 = true; r--; i...
#include <bits/stdc++.h> using namespace std; long long T, t, n, N, l, L, R; vector<int> v; pair<int, int> calcL() { for (n = l = 0; n < N; n++) { if ((l + (N - (n + 1))) > (L / 2)) break; l += (N - (n + 1)); } return pair<int, int>(n, 1 + n + (int)((L / 2) - l)); } void fill() { v.clear(); pair<int, ...
#include <bits/stdc++.h> using namespace std; long long n, l, r; int Go() { scanf("%lld %lld %lld", &n, &l, &r); long long len = r - l + 1; long long x = n; long long y = 0; long long start = 0; while (1) { y += 2 * (x - 1); x--; start++; if (x <= 0 || y >= l) break; } long long k = y - ...
#include <bits/stdc++.h> using namespace std; void solve() { long long n, l, r; cin >> n >> l >> r; if (n == 2) { for (long long i = l - 1; i < r; i++) { if (i & 1) cout << 2 << " "; else cout << 1 << " "; } return; } if ((r - 1) / 2 + 1 < n) { vector<long long> ans...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 10; long long n; long long pre[N]; long long cal(long long x) { if (x == n * (n - 1) + 1) return 1; long long p = lower_bound(pre + 1, pre + n + 1, x) - pre; long long b = x - pre[p - 1]; if (b & 1) return p; else return p + b / 2...
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<int, int>; using VI = vector<int>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; ll l, r; cin >> n >> l >> r; ll pre = 1; VI ans; for (int s = 1; s...
#include <bits/stdc++.h> using namespace std; long long int mod = 1000000007; inline long long int gcd(long long int a, long long int b) { return (b == 0) ? a : gcd(b, a % b); } inline long long int lcm(long long int a, long long int b) { return (a * b) / gcd(a, b); } inline long long int mymod(long long int A, lon...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; const double pi = acos(-1.0); const long long int inf = 0x3f3f3f3f3f3f3f3f; const long long int mod = 998244353; bool isPowerOfTwo(int x) { return x && (!(x & (x - 1))); } void fast() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } long lo...
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; int I_INF = 2e9; long long int L_INF = 1e18; void solve() { long long int n, i, j, l, r, index, ctr, num; cin >> n >> l >> r; vector<long long int> vect(n, 0); vect[0] = 2 * (n - 1); for (i = 1; i < n; i++) { vect[i] = 2 * (n - 1 -...
#include <bits/stdc++.h> using namespace std; long long gcd(long long n, long long m) { return n % m == 0 ? m : gcd(m, n % m); } long long getNum(long long x, long long n, long long pre, long long k) { if (k >= n) return 1; if ((x - pre) & 1) return k; else return k + (x - pre) / 2; } int main() { ios...
#include <bits/stdc++.h> using namespace std; using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } long long int gcdExtended(long long int a, long long int b, long long int *x, long long int *y) { if (a == 0) { *x = ...
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; long long l, r; cin >> l >> r; if (l == r && l == (n * (n - 1) + 1)) { cout << 1 << '\n'; return; } long long grp = n - 1; long long sum = 0; long long idx = 1; long long extra = 0; for (long long i = 1; i ...
#include <bits/stdc++.h> using namespace std; int ar[200002]; int main() { ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); ; long long t, n, l, r; cin >> t; while (t--) { cin >> n >> l >> r; if (l == n * (n - 1) + 1) { cout << "1\n"; continue; } long long s = 0, j...
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int t; cin >> t; while (t--) { solve(); } } const long long N = 1e5 + 5; std::vector<long long> cnt(N, 0); void solve() { long long n, l, r; cin >> n >> l >> r; for...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); std::cerr...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 1; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); if (f) x = -x; } template <typename T> inline void Mx(T &x, T y) {...
#include <bits/stdc++.h> using namespace std; long long int oo = numeric_limits<long long int>::max(); long long int MOD = 1e9 + 7; long long int comp(long long int n, long long int i) { return 2 * 1LL * (n - i); } int main() { cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); int t; cin >> t...
#include <bits/stdc++.h> using namespace std; int n; long long l, r; long long curlen; void add(int u) { curlen++; if (l <= curlen && curlen <= r) printf("%d ", u); return; } void Add(int u) { int cnt = (n - u) * 2; if (curlen + cnt >= l && curlen < r) { for (int i = u + 1; i <= n; i++) { add(u); ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; t = 1; cin >> t; for (int i1 = 0; i1 < t; ++i1) { long long n, l, r; cin >> n >> l >> r; vector<long long> v; long long c = (n - 1) * 2; long long s = c; ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 2e9; const long long INFLL = 1e18; const int MAX_N = 1; int T; long long N, L, R; int main() { scanf("%d", &T); while (T--) { scanf("%lld", &N); scanf("%lld%lld", &L, &R); long long n = 1; while (L <= R) { ...
#include <bits/stdc++.h> using namespace std; void display(int lvl, int lt, int rt) { for (int i = lt; i <= rt; i++) printf("%d ", ((i & 1) ? lvl : lvl + (i >> 1))); } int main() { int t, n, i, j, k; cin >> t; while (t--) { long long l, r, lvl, sz, sc, mx; scanf("%d %lld %lld", &n, &l, &r); mx =...
#include <bits/stdc++.h> using namespace std; long long ind[100005]; int main() { ios::sync_with_stdio(0); cin.tie(NULL); int t; cin >> t; for (int z = 1; z <= t; z++) { long long n; long long l, r; cin >> n >> l >> r; vector<int> res; ind[0] = 0; for (int i = 1; i < n; i++) { in...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int M = 1e5 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { long long n, l, r, f = 0; cin >> n >> l >> r; l--; if (r == n * (n - 1) + 1) r--, f = 1; long long nl = (n...
#include <bits/stdc++.h> using namespace std; const long long maxn = 200010; void solve(long long case_no) { long long n, l, r, st = 0; cin >> n >> l >> r; vector<long long> res; bool flag = false; for (long long i = 1; i <= n; i++) { if (st + res.size() >= r) break; if (!flag and st + 2 * (n - i) < l...
#include <bits/stdc++.h> using namespace std; long long l, r; int n; vector<long long> a; int main() { int tt; scanf("%d", &tt); while (tt--) { a.clear(); scanf("%d%lld%lld", &n, &l, &r); long long sum = 0, pos1 = 0; for (int i = 1; i <= n; i++) { if (1 + sum <= l && 1ll * (n - i) * 2 + sum ...
#include <bits/stdc++.h> using namespace std; const long long int N = 100005; void solve() { long long int i, j, k, n, m, ans = 0, cnt = 0, sum = 0; long long int l, r; cin >> n >> l >> r; vector<long long int> temp; for (i = 1; i < n; i++) { temp.push_back(2 * (n - i)); } temp.push_back(1); m = tem...
#include <bits/stdc++.h> using namespace std; #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") const int N = 100005; void solve() { long long n, s, e; cin >> n >> s >> e; if (s == n * n - n + 1) { cout << 1 << '\n'; return; } else { long long a = n *...
#include <bits/stdc++.h> using namespace std; template <class T, class U> istream &operator>>(istream &in, pair<T, U> &rhs) { in >> rhs.first; in >> rhs.second; return in; } template <class T, class U> ostream &operator>>(ostream &out, const pair<T, U> &rhs) { out << rhs.first; out << " "; out << rhs.second...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; const int maxn = 3e5 + 100; const int maxm = 2e6 + 100; const int inf = 0x3f3f3f3f; const double pi = acos(-1.0); int t; long long n; long long l, r; long long f(long long x) { return (2ll * n - x - 1) * x / 2ll; } void pt(long long x) { printf("%ll...
#include <bits/stdc++.h> using namespace std; const int N = 300005; int main() { long long test = 1; scanf("%d", &test); while (test--) { long long n; long long l, r; scanf("%lld %lld %lld", &n, &l, &r); if (l == 1LL * n * (n - 1) + 1) { printf("1\n"); continue; } long long sta...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long n, l, r; cin >> n >> l >> r; long long len = n * (n - 1) + 1; long long i = l; for (; i <= r && i <= 2 * (n - 2) + 1; i++) { if (i % 2) ...
#include <bits/stdc++.h> using namespace std; vector<long long> v; void insert(long long start, long long n) { long long lim = start + 1; while (lim <= n) { v.push_back(start); v.push_back(lim); lim++; } } void solve() { long long n, l, r; cin >> n >> l >> r; long long len = r - l + 1; long lo...
#include <bits/stdc++.h> using namespace std; long long l, r, curr = 1, n; vector<long long> ans; void rec(long long x) { if (x == n) { if (l <= curr && r >= curr) ans.push_back(1); return; } if (curr > r) return; if (curr + 2 * (n - x) - 1 < l) { curr += 2 * (n - x); rec(x + 1); return; }...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { long long n, l, r; cin >> n >> l >> r; long long cur = 0, num = 1, rest = n - 1; while (cur < l) { cur += (rest * 2); if (cur >= l) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ll inf = 1e18; const ll mod = 1e9 + 7; const ll MOD = 998244353; const ll MAX = 2e5 + 1; inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; } inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) ...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") using namespace std; void solve() { long long n, l, r; cin >> n >> l >> r; vector<long long> pre(n + 1, 0); for (int i = 1; i <= n; i++) { pre[i] = pre[i - 1] + 2 * (n - i); }...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { long long int n, l, r; cin >> n >> l >> r; long long int l1 = 0, r1 = n - 1, mid, pos = -1; while (l1 <= r1) { mid = l1 + (r1 - l1)...
#include <bits/stdc++.h> using ll = int64_t; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); ll T, n, l, r; cin >> T; for (int _ = 0, _Len = (T); _ < _Len; ++_) { cin >> n >> l >> r; ll index = 1; for (int i = 1, iLen = (n + 1); i < i...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0), ios_base::sync_with_stdio(0); int T; long long int i, j, p, q; cin >> T; long long int cnt2, N, L, R, cnt; for (int t = 0; t < T; t++) { cin >> N >> L >> R; cnt = 0; for (i = 1; i < N; i++) { if (L <= cnt + 2 * (N - i))...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; long long l, r; cin >> l >> r; long long h = 1; int i = 1; while (i < n && h + (n - i) * 2 <= l) { h += (n - i) * 2; i++; } while (i < n && h <= r) { for...
#include <bits/stdc++.h> using namespace std; long long Min(long long a, long long b) { return (a < b) ? a : b; } long long Max(long long a, long long b) { return (a < b) ? b : a; } long long gcd(long long m, long long n) { if (n == 0) return m; return gcd(n, m % n); } long long lcm(long long m, long long n) { retu...
#include <bits/stdc++.h> using namespace std; void work() { long long n, l, r; cin >> n >> l >> r; long long cnt = 0; long long sum = 0; long long f = 0; for (long long i = n - 1; i > 0; i--) { sum += i * 2; cnt++; if (sum >= l) { sum -= i * 2; f = 1; break; } } if (f =...
#include <bits/stdc++.h> using namespace std; void solve() { int n; long long l, r, len; cin >> n >> l >> r; l--, r--; len = (r - l + 1); int i = 0; for (; i < n; i++) { if ((n - i - 1) * 2 <= l) { l -= (n - i - 1) * 2; r -= (n - i - 1) * 2; } else { break; } } vector<int...
#include <bits/stdc++.h> using namespace std; int main() { long long t; scanf("%lld", &t); while (t--) { long long n, l, r; scanf("%lld%lld%lld", &n, &l, &r); long long suml = 0, sumr = 0; long long headl = 1, headr = -1; long long flag1 = 0; for (long long i = 1; i < n; ++i) { if (!...
#include <bits/stdc++.h> void proc() { int n; long long l, r; std::cin >> n >> l >> r; if (l == 1LL * n * (n - 1) + 1) { std::cout << 1 << std::endl; return; } int i = 0; long long t = 0; while (t + 2 * (n - 1 - i) < l) { t += 2 * (n - 1 - i); i++; } std::clog << i << std::endl; in...
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target( \ "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx,avx2,fma") using namespace std; vector<long long> v; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long a = 0, b = 0, c, d,...
#include <bits/stdc++.h> using namespace std; pair<int, int> p[105]; const int N = 1e5 + 10; long long d[N]; bool cmp(int a, int b) { return a > b; } int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { long long n, l, r; cin >> n >> l >> r; long...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; int T; int seq[maxn * 10 + 5]; long long sum, n, l, r; void mak(int p) { long long len = 0; for (int i = p; i <= n; i++) { for (int j = i + 1; j <= n; j++) { seq[++len] = i; seq[++len] = j; } if (len + sum >= r) break; } }...
#include <bits/stdc++.h> using namespace std; const int N = 100005; const int inf = 1000 * 1000 * 1000; const int mod = 998244353; mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count()); int t; int n; long long l, r; int main() { cin >> t; while (t--) { scanf("%d%lld%lld", &n, &l, &r); vecto...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; int q; void solve() { long long n, l, r, cnt = 0, cur = 0; cin >> n >> l >> r; for (long long i = 1; i <= n; i++) {...
#include <bits/stdc++.h> using namespace std; void brute_force(long long n) { set<int> graph[n + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == j) continue; graph[i].insert(j); } } int node = 1; vector<int> ans = {node}; long long edges = n * (n - 1); while ...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e6 + 5, MOD = 1e9 + 7, MAXLG = log2(MAX) + 1; const long long inf = 1e18 + 5; int arr[MAX]; vector<long long> v; int main() { ios::sync_with_stdio(false); cin.tie(NULL); ; int t; cin >> t; while (t--) { long long n, l, r; cin >> n >> l >...
#include <bits/stdc++.h> using namespace std; const int MAXN = 110; long long t, n, l, r, now; vector<int> q; int main() { cin >> t; while (t--) { while (q.size()) q.pop_back(); cin >> n >> l >> r; now = 1; for (long long i = (1); i <= (n - 1); i++) { if (now > r) break; if (now + 2 * (n...
#include <bits/stdc++.h> using namespace std; long long q, n, l, r, sum[100005]; signed main() { cin >> q; while (q--) { cin >> n >> l >> r; long long s = n * (n - 1), p = 0; if (l == s + 1) { puts("1"); continue; } sum[0] = 0; for (long long i = 1; i < n; i++) sum[i] = sum[i - 1...
#include <bits/stdc++.h> using namespace std; long long n; int main() { long long T; cin >> T; while (T-- > 0) { long long l, r; cin >> n >> l >> r; long long cnt = 0; for (int i = 1; i <= n - 1; ++i) { long long p = max(l, cnt + 1), q = min(cnt + 2 * (n - i), r); p -= cnt, q -= cnt; ...
#include <bits/stdc++.h> using namespace std; int main() { long long test; scanf("%lld", &test); while (test--) { long long i, j, k, l, r, n, m; scanf("%lld", &n); scanf("%lld", &l); scanf("%lld", &r); long long pre = 1, cub = 0, num; for (i = 1; i < n; i++) { if (l <= cub + 2 * (n -...