solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
for i in range(int(input())):
n, l, r = map(int, input().split())
l -= 1
r -= 1
c = 0
for j in range(n):
if (c + (n - j - 1) * 2 < l or c > r):
c += (n - j - 1) * 2
continue
for k in range(j + 1, n):
if (l <= c <= r):
print(j + 1, e... | 10 | PYTHON3 |
from sys import stdin
def allWays(start, verts, done, stack, n):
global valid
if not valid:
return
stack.append(start)
if len(done) == len(verts):
print(stack)
stack.pop()
valid = False
return
for x in range(1,n+1):
if start != x and not (start,x) in ... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
# -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] fo... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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 -... | 10 | CPP |
import io
import os
from collections import Counter, defaultdict, deque
def solve(N, L, R):
M = R - L + 1
ans = []
count = 0
done = False
for i in range(N - 1, -1, -1):
if count + 2 * i < L:
count += 2 * i
else:
curr = N - i
for j in range(curr ... | 10 | PYTHON3 |
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in... | 10 | PYTHON3 |
#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... | 10 | CPP |
# HEY STALKER
for _ in range(int(input())):
n, l, r = map(int, input().split())
z = 0
idx = 0
sd = (n-1)*2
lst = (n*(n-1))+1
while z < l:
if sd <= 0:
z += 1
break
idx += 1
z += sd
sd -= 2
m = idx-1
c = (n-1)*2
sm = 0
for t i... | 10 | PYTHON3 |
#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 = ... | 10 | CPP |
#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 ... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
t = int(input())
for case_num in range(t):
n, l, r = map(int, input().split(' '))
if l == n * (n-1) + 1:
print(1)
continue
total = 0
unvisited = n - 1
while total < l:
total += unvisited * 2
unvisited -= 1
unvisited += 1
total -= unvisited * 2
current = n ... | 10 | PYTHON3 |
import sys
input = sys.stdin.readline
T=int(input())
for tests in range(T):
n,l,r=map(int,input().split())
begin=1
while l>(n-begin)*2+1:
if begin==n:
break
l-=(n-begin)*2
r-=(n-begin)*2
begin+=1
#print(begin,l,r)
if begin==n:
ANS=[n,1]
el... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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) {... | 10 | CPP |
# coding: utf-8
# Your code here!
def solve():
n, l, r = map(int, input().split())
def where(x):
if x == n*(n-1) + 1:
return 1
else:
l = 0
r = n + 1
while r - l > 1:
m = (l + r)//2
if (2*n-1-m)*(m) < x:
... | 10 | PYTHON3 |
# region fastio # from https://codeforces.com/contest/1333/submission/75948789
import sys, io, os
BUFSIZE = 8192
class FastIO(io.IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = io.BytesIO()
self.writable = "x" in file.mode or "r" not in file.mo... | 10 | PYTHON3 |
import sys
input = sys.stdin.readline
from collections import *
def binary_search1():
l, r = 1, n-1
while l<=r:
m = (l+r)//2
if acc[m]-acc[1]+1<=left:
l = m+1
else:
r = m-1
return r
def binary_search2():
l, r = 1, n-1
whil... | 10 | PYTHON3 |
import sys
input = sys.stdin.readline
def li():return [int(i) for i in input().rstrip('\n').split()]
def val():return int(input().rstrip('\n'))
for _ in range(val()):
n,l,r = li()
orig = r
l -= 1
r -= l
currleft = 0
curs = n - 1
while curs and currleft + 2*curs <= l:
currleft +=... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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);
... | 10 | CPP |
#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;
... | 10 | CPP |
import math
# решена
def task_1343_c():
b = int(input())
array = [int(num) for num in input().split()]
maxPositive = 0
minNegative = -10000000000
res = 0
for i in range(b):
if array[i] < 0:
if i != 0 and array[i - 1] >= 0:
res += maxPositive
... | 10 | PYTHON3 |
#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) {
... | 10 | CPP |
def slv(n,l, r):
l-=1
r-=1
c = 0
ans = []
for i in range(1, n):
nl,nr = c, c + 2*(n-i)-1
c = nr+1
if l > nr:
continue
for j in range(max(l, nl), min(r, nr)+1):
if j %2 == 0:
ans.append(i)
else:
ans.ap... | 10 | PYTHON3 |
#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 =... | 10 | CPP |
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): ret... | 10 | PYTHON3 |
#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... | 10 | CPP |
def genGroup(lo, n):
if lo == n:
return [1]
s = []
for i in range(lo+1, n+1):
s.append(lo)
s.append(i)
return s
for tc in range(int(input())):
n, beg, end = map(int, input().split())
if beg == n*(n-1)+1:
print(1)
else:
past = 0
i = 1
w... | 10 | PYTHON3 |
#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... | 10 | CPP |
#code
import sys
import math as mt
#input=sys.stdin.buffer.readline
t=int(input())
#tot=0
for __ in range(t):
#n=int(input())
#l=list(map(int,input().split()))
n,l,r=map(int,input().split())
j=1
k=2*n-2
mul=1
k=2*n-2
r1=k
l1=1
for i in range(n-2):
if l... | 10 | PYTHON3 |
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.wr... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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 ... | 10 | CPP |
#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... | 10 | CPP |
#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 *... | 10 | CPP |
# -*- coding: utf-8 -*-
import os
import sys
from io import BytesIO, IOBase
INF = 2**62-1
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.... | 10 | PYTHON3 |
#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... | 10 | CPP |
import sys
readline = sys.stdin.readline
def overlap(a, b, c, d):
if b <= c or d <= a:
return False
return True
T = int(readline())
Ans = [None]*T
for qu in range(T):
N, l, r = map(int, readline().split())
l -= 1
ans = []
num =[0] + [2*(N-i-1) for i in range(N-1)] + [1]
for i in r... | 10 | PYTHON3 |
from sys import stdin, stdout
import collections
for _ in range(int(input())):
n, l, r = map(int, input().split())
loop = r-l+1
if r==n*(n-1)+1:
loop-=1
ans = ""
t_l = 2*(n-1)
t_r = 2*(n-1)
i = 1
while l>t_l:
i += 1
if i!=n:
t_l+=2*(n-(i))
else... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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... | 10 | CPP |
for t in range(int(input())):
n,l,r=map(int,input().split())
b=1
for i in range(1,n):
a=b
b+=2*(n-i)
if l<b:
break
x,y=i,(l-a)//2+i+1
b=(l-a)%2
for _ in range(r-l):
if b:
print(y,end=" ")
y+=1
if y==n+1:
x+=1
y=x+1
else:
print(x,end=" ")
... | 10 | PYTHON3 |
#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)
... | 10 | CPP |
#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... | 10 | CPP |
#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;
}... | 10 | CPP |
"""
NTC here
"""
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
def iin(): return int(input())
def lin(): return list(map(int, input().split()))
def main():
T = iin()
while T:
T-=1
n, l, r= lin()
l-=1
r-=1
ch, ch1 = n-1, 1
sm = ... | 10 | PYTHON3 |
#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) {
... | 10 | CPP |
#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) ... | 10 | CPP |
def oracle(n, start, end):
nod = 0
t = n - 1
ii = 0
while start - ii > t*2:
if t == 0:
nod += 1
break
nod += 1
ii += t*2
t -= 1
if t < -10:
import sys
sys.exit()
R = []
for cur in range(nod, n):
for v... | 10 | PYTHON3 |
#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);
}... | 10 | CPP |
#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)... | 10 | CPP |
import itertools as it
import os
def items(k, n):
return 2 * k * n - k * (k + 1)
def b(l, n):
if l > n * (n - 1):
return n
low = 1
high = n - 1
while low < high:
mid = (high + low) // 2
if items(mid, n) < l:
low = mid + 1
else:
high = mid
... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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))... | 10 | CPP |
from bisect import bisect_left, bisect_right
class Result:
def __init__(self, index, value):
self.index = index
self.value = value
class BinarySearch:
def __init__(self):
pass
@staticmethod
def greater_than(num: int, func, size: int = 1):
"""Searches for smallest eleme... | 10 | PYTHON3 |
from math import floor
T = int(input())
for _ in range(T):
n, l, r = map(int, input().split())
o_r = r
ans = []
if l == n * (n - 1) + 1:
print(1)
continue
i = 1
while l > 0:
if l <= 2 * (n - i):
for j in range(i + 1, n + 1):
l -= 1
... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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 =... | 10 | CPP |
#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... | 10 | CPP |
import io,os
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys
def query(n,l,r):
begin=1
while l>(n-begin)*2+1:
if begin==n:
break
l-=(n-begin)*2
r-=(n-begin)*2
begin+=1
Ans=[]
ans_l=0
while ans_l<=r:
if begin==n:
An... | 10 | PYTHON3 |
# from debug import debug
t = int(input())
for ii in range(t):
n, l, r = map(int, input().split())
s = []
count = 1
ans = count*(2*(n-1) + 1- count)
while ((n-count)>0 and ans<l):
count+=1
ans = count*(2*(n-1) + 1- count)
count-=1
remain = l-count*(2*(n-1) + 1- count)-1
val = 0
b = 0
for i in range(cou... | 10 | PYTHON3 |
#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 (!... | 10 | CPP |
import math
import sys
from collections import defaultdict,Counter,deque,OrderedDict
import bisect
#sys.setrecursionlimit(1000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c... | 10 | PYTHON3 |
#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... | 10 | CPP |
def f(n, k):
return n * k - k + n * k - k * k
def af(n, p):
if p == n * (n - 1):
return 1
l = 0
r = n + 1
while r - l > 1:
m = (l + r) // 2
if f(n, m) <= p:
l = m
else:
r = m
if (p - f(n, l)) % 2 == 0:
return r
return (p - f(n, ... | 10 | PYTHON3 |
#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,... | 10 | CPP |
def ss(a,d,n):
return n*(2*a+(n-1)*d)//2
T = int(input())
for loop in range(T):
n,l,r = map(int,input().split())
ans = []
lb = 0
rb = n-1
while rb - lb != 1:
m = (lb+rb) // 2
if ss(2*n-2,-2,m) >= l:
rb = m
else:
lb = m
BB = rb
in... | 10 | PYTHON3 |
import sys
import io, os
def main():
input=sys.stdin.readline
t=int(input())
for i in range(t):
n,l,r=map(int,input().split())
end=[]
start=(n-1)*2
copy=0
count,ok=0,True
for i in range(1,n+1):
if (count+start)<l:
count+=start
... | 10 | PYTHON3 |
def calcStartIndex(vertex,n):
i=vertex
return 1+2*(i-1)*n-i*i+i
def main():
t=int(input())
allans=[]
for _ in range(t):
n,l,r=readIntArr()
startVertex=1
b=n
while b>0:
while startVertex+b<=n and calcStartIndex(startVertex+b,n)<=l:
... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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;
}
}... | 10 | CPP |
#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... | 10 | CPP |
#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++) {... | 10 | CPP |
#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 ... | 10 | CPP |
#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 >... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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;
... | 10 | CPP |
#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 -... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
long long size = (r - l) + 1;
l--;
r--;
long long curr = 0;
long long startVer = 1;
while (... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long n, l, r, curr;
void solve(long long depth = 0) {
if (depth == n) {
if ((curr <= r)) cout << 1 << " ";
return;
}
if ((curr + 2 * (n - depth - 1) - 1) < l) {
curr += 2 * (n - depth - 1);
solve(depth + 1);
return;
} else if ((curr > r)) {
... | 10 | CPP |
for _ in range(int(input())):
n, l, r = map(int, input().split())
x = 0
off = 0
for i in range(1, n+1):
if x + 2 * (n-i) >= l:
off = l-x-1
break
x += 2 * (n-i)
series = []
while len(series) < (r-l+1) + off:
for j in range(i+1, n+1):
series.append(i)
series.append(j)
i += 1
if i >= n:
... | 10 | PYTHON3 |
import sys
input = sys.stdin.buffer.readline
def prog():
for _ in range(int(input())):
n,l,r = map(int,input().split())
l -= 1
r -= 1
a = 1
new = 2*(n-a)
while new < l:
l -= new
r -= new
a += 1
new = 2*(n-a)
tota... | 10 | PYTHON3 |
import sys
input = sys.stdin.readline
for t in range(int(input())):
n, l, r = map(int, input().split(" "))
startSection = 2*(n-1)
startCount = 1
while(l>startSection):
startCount = startCount + 1
if(startCount<n):
startSection = startSection+2*(n-startCount)
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const int xn = -20 + 10;
const int xm = 2e1 + 10;
const int SQ = 450;
const int sq = 1e3 + 10;
const int inf = 1e9 + 10;
const long long INF = 1e18 + 10;
long long power(long long a, long long b) {
return (!b ? 1
: (b & 1 ? a * p... | 10 | CPP |
t = int(input())
for i in range(t):
n, l, r = map(int, input().split())
if (l == n * (n - 1) + 1):
print(1)
continue
left, right, summ = 0, n, 0
while (left != right - 1):
mid = (left + right) // 2;
tmp = n * mid - (mid * (mid + 1) // 2)
if (2 * tmp < l):
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::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 long idx = 1;
bool p = false;
bool end = false;
for (long long i = 1; i <= n - 1; i++) {
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1);
const long long INF = 1e18;
const int MX = 100001;
int T, n;
long long l, r;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> T;
while (T--) {
cin >> n >> l >> r;
long long first_elt = 1;
long long num_visited = 0;
... | 10 | CPP |
import sys
input=sys.stdin.readline
t=int(input())
for _ in range(t):
n,l,r=map(int,input().split())
begin=1
while l>(n-begin)*2+1:
if begin==n:
break
l-=(n-begin)*2
r-=(n-begin)*2
begin+=1
if begin==n:
ans=[n,1]
else:
ans=[]
while len(ans)<=r:
if begin==n:
ans.... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
} els... | 10 | CPP |
for f in range(int(input())):
n,l,r=map(int,input().split())
s=[0]*(r-l+1)
i=1
p=1
t=2*n-((2*n)**2-4*l)**0.5
t=t/2
t=int(t)
t-=1
if t>0:
p=2*(t*n-(t*(t+1))//2)
p+=1
i+=t
while p+2*(n-i)<=l and i<n:
p+=2*(n-i)
i+=1
j=i+1
while p+2<=l... | 10 | PYTHON3 |
import sys
input = sys.stdin.buffer.readline
from bisect import bisect_left
T = int(input())
for _ in range(T):
n, l, r = map(int, input().split())
ls = [ (n-u)*2 for u in range(n+1) ]
ls[0] = 1
for i in range(1, n+1):
ls[i] += ls[i-1]
p = bisect_left(ls, l)
sp = []
if p == 0:
... | 10 | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.