solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
for nt in range(int(input())):
n,a,b=map(int,input().split())
if n==2:
l=[1,2,1]
print (*l[a-1:b])
continue
k=n
prev=0
for j in range(a,b+1):
i=j-prev
while k>1:
if i<=2*(k-1):
if i%2:
print (n-k+1,end=" ")
else:
print (i//2+(n-k+1),end=" ")
break
else:
i-=2*(k-1)
prev... | 10 | PYTHON3 |
import sys
input = sys.stdin.buffer.readline
from bisect import bisect_left
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
B = [0]
for i in range(1, 2*10**5):
B.append(i*(i+1)//2)
def solve(n, N):
M = N*(N-1)
n %= M
if n%2 == 0:
rem = (M - n)//2
ind = bi... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
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;
vector<long long> pre(n + 1);
for (int i = 1; i <= n; i++) {
pre[i] = pre[i - 1] + 2 * (n - i);
}
pre[n]++;
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
long long s = 0;
long long i;
for (i = 1; i <= n - 1; i++) {
s += 2 * (n - i);
if (l <= s) {
s = s - 2 * (n - i);
break;
}
}
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, l, r;
cin >> n >> l >> r;
if (l == n * (n - 1LL) + 1LL) {
cout << 1 << '\n';
return;
}
long long suma = 0LL;
long long trenutni = (long long)n - 1LL;
while (trenutni > 0) {
if (suma + 2 * trenutni >= l) break;
suma +... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007, N = 1e5 + 5, M = 1e5 + 5, INF = 0x3f3f3f3f;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxc = 1e5;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
long long k = 0;
long long n, l, r;
cin >> n >> l >> r;
for (long long i = 2 * (n - 1); i; k += i, i -= 2) {
for (long long j =... | 10 | CPP |
import math
import sys
# input = sys.stdin.readline
T=int(input())
for _ in range(T):
n,l,r=map(int,input().split())
size=r-l+1
run=0
ans=[]
for i in range(1,n):
run+=2*(n-i)
# print(run)
if l<=run:
prev=run-2*(n-i)
gone=l-prev-1
size+=gone
# print(gone)
cur=0
now=i
nex=i+1
flag=True... | 10 | PYTHON3 |
from sys import stdin, stdout
import math
def expandList(i,n):
if i!=n:
out = []
for j in range(n-i):
out.append(i)
out.append(i+j+1)
return out
else:
return [1]
T = int(stdin.readline().rstrip())
for iTest in range(T):
n,l,r = list(map(int,stdin.r... | 10 | PYTHON3 |
# import sys
# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
def go():
# n=int(input())
n,l,r = map(int, input().split())
# a = sorted(map(int, input().split()),reverse=True)
tot = n*(n-1)+1
add=[]
if r==tot:
add=['1']
r-=1
res=[]
... | 10 | PYTHON3 |
import sys
def data(): return sys.stdin.buffer.readline().strip()
out=sys.stdout.write
def mdata(): return map(int, data().split())
for t in range(int(data())):
n,l,r=mdata()
a=l
for i in range(1,n+1):
if 2*(n-i)<=a:
a-=2*(n-i)
else:
break
cnt=l
ans=[]
if... | 10 | PYTHON3 |
T = int(input().strip())
for t in range(T):
n, l, r = map(int, input().strip().split())
if l == n*(n-1)+1:
print(1)
continue
k = int((2*n-1-((2*n-1)**2-4*l)**0.5)/2)
if l <= 2*k*n- k*(k+1): k -= 1
if l > 2*(k+1)*n - (k+1)*(k+2): k += 1
m = 2*k*n - k*(k+1)
s = []
k += 1
... | 10 | PYTHON3 |
from sys import *
t = int(stdin.readline())
import math
for _ in range(t):
n,l,r = list(map(int,stdin.readline().split(' ')))
if(l == n*n-n+1):
print('1')
continue
k = math.ceil(((2*n-1) - math.sqrt((2*n-1)**2 - 4*l))/2)
s = k*(2*n-1 -k)
sl = 2*(n-k)
lb = k
eb = k+1+math... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
struct R {
long long int nd, i;
};
int main() {
long long int n, l, r, st;
scanf("%*d");
while (~scanf("%lld %lld %lld", &n, &l, &r)) {
long long int p, i, j, nd;
vector<R> v;
v.push_back({1, 1});
for (p = 1, i = 2, j = n - 1; i < n; i++, j--) v.push... | 10 | CPP |
# |
# _` | __ \ _` | __| _ \ __ \ _` | _` |
# ( | | | ( | ( ( | | | ( | ( |
# \__,_| _| _| \__,_| \___| \___/ _| _| \__,_| \__,_|
import sys
import collections
def read_line():
return sys.stdin.readline()[:-1]
def read_int()... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 300010;
long long t, n, a[N], b[N], x[N];
int main() {
scanf("%lld", &t);
while (t--) {
long long l, r;
scanf("%lld", &n);
scanf("%lld%lld", &l, &r);
long long tot = r - l + 1;
long long high = n - 1, low = 1, mid, s = -1;
whi... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
vector<int> func(int n, long long l, long long r) {
long long start = 1;
long long end = 2 * 1ll * (n - 1);
vector<int> ans;
if (start <= l && l <= end) {
while (l <= r && l <= end) {
if (l % 2 == 1) {
ans.push_back(1);
} else {
ans.p... | 10 | CPP |
# problem 2
def calc(N, index):
# find the number when given (N,index)
if index == 1 or index == N*(N-1)+1:
return 1
else:
wave_l = 1
wave_r = N
while wave_r-wave_l > 1:
M = (wave_l+wave_r)//2
if (2*N-M)*(M-1) < index:
wave_l = M
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 2e5 + 2;
int main() {
int t;
scanf("%d", &t);
while (t--) {
long long n, l, r;
scanf("%lld", &n);
scanf("%lld", &l);
scanf("%lld", &r);
long long cur = 0, val = 2 * (n - 1), ind = 1;
while (cur + v... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long n, t, l, r, o, e, pos;
long long Find(long long k) {
long long t = k;
if (t % 2 == 1)
t = (t + 1) / 2;
else
t /= 2;
for (long long i = 0; i <= n - 1; i++) {
if (n * i - i * (i + 1) / 2 < t && t <= n * (i + 1) - (i + 1) * (i + 2) / 2)
retu... | 10 | CPP |
import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
n, l, r = map(int, input().split())
s = 1
while l > (n-s)*2:
if s == n:
break
l -= (n-s)*2
r -= (n-s)*2
s += 1
#print(s, l, r)
ans = []
while len(ans) <= r:
i... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
out << '(' << p.first << ", " << p.second << ')';
return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
long long l = v.size();
for (long... | 10 | CPP |
import os
import sys
from io import BytesIO, IOBase
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.write if self.writa... | 10 | PYTHON3 |
import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
n, l, r = map(int, input().split())
s = 1
while l > (n-s)*2+1:
if s == n:
break
l -= (n-s)*2
r -= (n-s)*2
s += 1
#print(s, l, r)
if s == n:
ans = [n, 1]
else:... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long int i, j, n, m, k;
long long int l, r;
cin >> n >> l >> r;
bool var1 = 0;
long long int var2 = 0, var = 0;
if (r == (n * (n - 1LL)) + 1LL) {
var1 = 1;
r--;
} else {
long long int o = 0;
while (o < 2) o++;
}
long lon... | 10 | CPP |
def main():
t=int(input())
for _ in range(t):
n,l,r=map(int,input().split())
if l==n*n-n+1:
print(1)
continue
if r==n*n-n+1:
r_g=n
for i in range(n-1):
if l>2*n-2-2*i:
l-=2*n-2-2*i
else:
l... | 10 | PYTHON3 |
#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;
}... | 10 | CPP |
#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";
... | 10 | CPP |
#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... | 10 | CPP |
#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;... | 10 | CPP |
import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
n, l, r = map(int, input().split())
lb, ub = 0, n
while ub - lb > 1:
m = (lb + ub) // 2
if m * (2*n-m-1) < l:
lb = m
else:
ub = m
i = ub
s = lb * (2*n-lb-1) + 1
j = (l - s +... | 10 | PYTHON3 |
#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 = ... | 10 | CPP |
#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... | 10 | CPP |
#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 =... | 10 | CPP |
#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 (... | 10 | CPP |
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
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... | 10 | PYTHON3 |
for nt in range(int(input())):
w,a,b=map(int,input().split())
if w==2:
l=[1,2,1]
print (*l[a-1:b])
continue
k=w
prev=0
for j in range(a,b+1):
i=j-prev
while k>1:
if i<=2*(k-1):
if i%2:
print (w-k+1,end=" ")
else:
print (i//2+(w-k+1),end=" ")
break
else:
i-=2*(k-1)
prev... | 10 | PYTHON3 |
from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
n,l,r = map(int,input().split())
tab = [-1,1]
cyk = 0
for i in range(n):
cyk += 2*(n-i-1)
tab.append(cyk + 1)
tab.append(1012809128301279797787789798789798798)
i = 0
start = i
while True:
if tab[i + 1] > l:
start = i
br... | 10 | PYTHON3 |
t=int(input())
for _ in range(t):
n,l,r=map(int,input().split())
L=[0]
tt=2*(n-1)
for i in range(n):
L.append(tt)
tt-=2
L[-1]=1
temp=0
ct=r-l+1
c=0
tot=0
for i in range(1,len(L)):
if(tot+L[i]<l):
tot+=L[i]
else:
rem=l-tot... | 10 | PYTHON3 |
#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 ... | 10 | CPP |
#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;... | 10 | CPP |
import bisect
t=int(input())
for _ in range(t):
n,l,r=map(int,input().split())
ans=[]
sums=[]
tmp=0
for i in range(n-1,0,-1):
tmp+=i
sums.append(tmp)
for i in range(l-1,r):
if i%2==0:
k=i//2
g=bisect.bisect_right(sums,k)
tmp=0
if g==n-1:
ans.append(1)
else:... | 10 | PYTHON3 |
#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) {
... | 10 | CPP |
#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;
... | 10 | CPP |
#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 -... | 10 | CPP |
#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);
}... | 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;
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;
... | 10 | CPP |
#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... | 10 | CPP |
#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 = ... | 10 | CPP |
import sys;input=sys.stdin.readline
t, = map(int, input().split())
def gen(k):
return [k+(i+1)//2 if i%2 else k for i in range(2*(n-k))]
for _ in range(t):
n, s, e = map(int, input().split())
k, sm = 0, 0
while sm < s and k < n-1:
k += 1
sm += 2*(n-k)
if sm < s:
k+=1
k... | 10 | PYTHON3 |
from collections import *
import sys
try: inp = raw_input
except: inp = input
def err(s):
sys.stderr.write('{}\n'.format(s))
def ni():
return int(inp())
def nl():
return [int(_) for _ in inp().split()]
def solve():
n, L, R = nl()
L -= 1
R -= 1
SM = 0
out = []
for i in range(1, n)... | 10 | PYTHON3 |
#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;
... | 10 | CPP |
import sys
d = []
def bins(k, n):
l = 0
r = n-2
while l != r:
mid = (l+r+1)//2
if d[mid] <= k:
l = mid
else:
r = mid-1
# print("debug:", l)
ex = k - d[l]
if ex &1:
f = ex//2
return f + l + 2
else:
return l+1
for q in... | 10 | PYTHON3 |
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;
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... | 10 | CPP |
for _ in range(int(input())):
n, l, r = map(int, input().split())
cursum = 0
curn = n - 1
while curn > 0 and (cursum + (curn << 1)) < l:
cursum += curn << 1
curn -= 1
fix = n - curn
d = False
i = fix
nexti = fix + 1
# print(cursum, l, i, nexti)
for _ in range(curs... | 10 | PYTHON3 |
import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
n, l, r = map(int, input().split())
s = 1
while l > (n-s)*2+1:
#if s == n:
#break
l -= (n-s)*2
r -= (n-s)*2
s += 1
#print(s, l, r)
if s == n:
ans = [n, 1]
els... | 10 | PYTHON3 |
import sys
from collections import defaultdict
from copy import copy
R = lambda t = int: t(input())
RL = lambda t = int: [t(x) for x in input().split()]
RLL = lambda n, t = int: [RL(t) for _ in range(n)]
def solve():
n, l, r = RL()
if l == n*(n-1)+1:
print(1)
return
l -= 1
r -= 1
D = ((2*n-1)**2-4*l... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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) + ... | 10 | CPP |
#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 % ... | 10 | CPP |
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threadi... | 10 | PYTHON3 |
#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, ... | 10 | CPP |
#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")... | 10 | CPP |
#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... | 10 | CPP |
#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)))... | 10 | CPP |
#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... | 10 | CPP |
#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 = ... | 10 | CPP |
CASES = int(input())
answers = []
while (CASES):
CASES -= 1
num, begin, end = [int(x) for x in input().split(" ")]
sequence = []
index = 1
tempB = begin
tempE = end
temp = 2*(num - index)
while (tempB > temp and index < num):
tempB -= temp
tempE -= temp
index... | 10 | PYTHON3 |
import sys
input = sys.stdin.buffer.readline
for t in range(int(input())):
n,l,r = map(int,input().split())
for i in range(l,min(2*(n-2)+1,r) + 1):
print('1' if i & 1 else i//2 + 1 , end = ' ')
n_set = n
set_idx = 2*(n-2) + 2
while(n_set > 2):
ls = l - set_idx + 1
rs = ... | 10 | PYTHON3 |
def find(a):
global k, tot
if a > n * (n - 1):
return 1
while a > tot + (n - k) * 2:
tot += (n - k) * 2
k += 1
if a & 1:
return k
return (a - tot) // 2 + k
for _ in range(int(input())):
n, l, r = map(int, input().split())
global k, tot
k = 1
tot = 0
... | 10 | PYTHON3 |
#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) {
... | 10 | CPP |
#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] << " ";
... | 10 | CPP |
from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def... | 10 | PYTHON3 |
for _ in range(int(input())):
n,l,r = map(int,input().split())
s=0
ans=[]
for i in range(1,n):
gap2=i
t=i
if s+(n-i)*2 >=l :
for j in range(l,r+1):
gg=(j-s)//2
if j%2==1:
ans.append(gap2)
... | 10 | PYTHON3 |
#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) {
... | 10 | CPP |
#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;
... | 10 | CPP |
#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... | 10 | CPP |
test = int(input())
for _ in range(test):
n , l , r = [int(x) for x in input().split()]
start = 1
it = 1
if l == n*(n-1) + 1:
print('1')
continue
while start < l:
start += (n-it)*2
it += 1
if start != l:
it -= 1
start -= (n - it)*2
a = it
b... | 10 | PYTHON3 |
#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... | 10 | CPP |
def main():
for _ in inputt():
n, l, r = inputi()
i = 1
l -= 1
if l == n * (n - 1):
print(1)
continue
while l >= 2 * (n - i):
l -= 2 * (n - i)
r -= 2 * (n - i)
i += 1
j = i + 1 + l // 2
while l < r:... | 10 | PYTHON3 |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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 +=... | 10 | CPP |
#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 <... | 10 | CPP |
#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
... | 10 | CPP |
#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... | 10 | CPP |
#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 -... | 10 | CPP |
#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;... | 10 | CPP |
#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... | 10 | CPP |
#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, ... | 10 | CPP |
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO, IOBase
def solve(n,l,r):
fir,st = 0,1
while st < n:
x = 2*(n-st)
if fir+x >= l:
break
fir += x
st += 1
if st == n:
return [1]
ans = []
for z in ran... | 10 | PYTHON3 |
#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 - ... | 10 | CPP |
import sys
import math
input = sys.stdin.readline
from functools import cmp_to_key;
def pi():
return(int(input()))
def pl():
return(int(input(), 16))
def ti():
return(list(map(int,input().split())))
def ts():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
... | 10 | PYTHON3 |
from sys import stdin
from collections import deque
mod = 10**9 + 7
import sys
import random
# sys.setrecursionlimit(10**6)
from queue import PriorityQueue
# def rl():
# return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdi... | 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 |
from sys import stdin, gettrace
from math import sqrt
if not gettrace():
def input():
return next(stdin)[:-1]
# def input():
# return stdin.buffer.readline()
def main():
def solve():
n,l,r = map(int, input().split())
lv = int((2*n+1 - sqrt((2*n-1)**2 -4*(l-1)))/2)
lvs = -... | 10 | PYTHON3 |
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from heapq import heapify,heappush,heappop
def main():
for _ in range(int(input())):
n,l,r=map(int,input().split())
l-=1
ptrn=[]
for i in range(2,10**5+2):
... | 10 | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.