exec_outcome stringclasses 1 value | code_uid stringlengths 32 32 | file_name stringclasses 111 values | prob_desc_created_at stringlengths 10 10 | prob_desc_description stringlengths 63 3.8k | prob_desc_memory_limit stringclasses 18 values | source_code stringlengths 117 65.5k | lang_cluster stringclasses 1 value | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_time_limit stringclasses 27 values | prob_desc_sample_outputs stringlengths 2 796 | prob_desc_notes stringlengths 4 3k ⌀ | lang stringclasses 5 values | prob_desc_input_from stringclasses 3 values | tags listlengths 0 11 | src_uid stringlengths 32 32 | prob_desc_input_spec stringlengths 28 2.37k ⌀ | difficulty int64 -1 3.5k ⌀ | prob_desc_output_spec stringlengths 17 1.47k ⌀ | prob_desc_output_to stringclasses 3 values | hidden_unit_tests stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PASSED | ead541e17d52244b1849391f2e8ae463 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class Main {
static boolean lol(int[][]arr,int n,int m){
int ff=0;
for (int i=0; i<n; i++){
for ( int j=0; j<m; j++){
if ( arr[i][j]==1){
ff = 1;
break;
}
}
if ( ff==1)
break;
}
if ( ff==1)
return true;
return false;
}
static void swap(int[]arr, int a,int b){
int temp = arr[a];
arr[a] = arr[b];
arr[b] = temp;
}
static long abs(int[] arr, int a,int b){
if ( arr[a]>=arr[b])
return arr[a]-arr[b];
return arr[b]-arr[a];
}
static int absOfNum(int a, int b){
if ( a>=b)
return (a-b);
return (b-a);
}
static String oddOrEven(int n){
int a = n & 1;
if ( a==0)
return "Even";
return "Odd";
}
static long gcd(long a,long b){
if ( b==0)
return a;
return gcd(b,a%b);
}
static long lcm(long a,long b){
return (a*b)/gcd(a,b);
}
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int test = sc.nextInt();
for ( int t=0; t<test; t++){
int n = sc.nextInt();
long l = sc.nextLong();
long r = sc.nextLong();
int cc= 0;
long[] arr = new long[n];
for ( int i=0; i<n; i++){
if ( l%(i+1)==0)
arr[i] = l;
else {
long x = l+i+1-(l%(i+1));
if ( x<=r)
arr[i] = x;
else {
cc = 1;
break;
}
}
}
if ( cc==0){
System.out.println("YES");
for ( int i=0; i<n; i++)
System.out.print(arr[i]+" ");
System.out.println();
}
else
System.out.println("NO");
// for ( int i=0; i<n; i++){
// arr[i] = l;
// while( arr[i]%(i+1)!=0 && arr[i]<r)
// arr[i]++;
// if ( arr[i]%(i+1)!=0){
// cc = 1;
// break;
// }
// }
// if ( cc==1)
// System.out.println("NO");
// else {
// System.out.println("YES");
// for ( int i=0; i<n; i++)
// System.out.print(arr[i]+" ");
// System.out.println();
// }
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 8b7fd1805476c664c193bec63a05344a | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | // package c1708;
//
// Codeforces Round #808 (Div. 2) 2022-07-16 07:35
// B. Difference of GCDs
// https://codeforces.com/contest/1708/problem/B
// time limit per test 1 second; memory limit per test 256 megabytes
// public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*class\s+(\w+).*'
//
// You are given three integers n, l, and r. You need to construct an array a_1,a_2,...,a_n (l<=
// a_i<= r) such that \gcd(i,a_i) are all distinct or report there's no solution.
//
// Here \gcd(x, y) denotes the <a
// href="https://en.wikipedia.org/wiki/Greatest_common_divisor">greatest common divisor (GCD)</a> of
// integers x and y.
//
// Input
//
// The input consists of multiple test cases. The first line contains a single integer t (1<= t<=
// 10^4)-- the number of test cases. The description of the test cases follows.
//
// The first line contains three integers n, l, r (1 <= n <= 10^5, 1<= l<= r<= 10^9).
//
// It is guaranteed that the sum of n over all test cases does not exceed 10^5.
//
// Output
//
// For each test case, if there is no solution, print "NO" (without quotes). You can print letters
// in any case (upper or lower).
//
// Otherwise, print "YES" (without quotes). In the next line, print n integers a_1,a_2,...,a_n-- the
// array you construct.
//
// If there are multiple solutions, you may output any.
//
// Example
/*
input:
4
5 1 5
9 1000 2000
10 30 35
1 1000000000 1000000000
output:
YES
1 2 3 4 5
YES
1145 1926 1440 1220 1230 1350 1001 1000 1233
NO
YES
1000000000
*/
// Note
//
// In the first test case, \gcd(1,a_1),\gcd(2,a_2),...,\gcd(5,a_5) are equal to 1, 2, 3, 4, 5,
// respectively.
//
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.invoke.MethodHandles;
import java.util.Random;
import java.util.StringTokenizer;
public class C1708B {
static final int MOD = 998244353;
static final Random RAND = new Random();
static int[] solve(int n, int l, int r) {
int[] ans = new int[n];
// *** Note that ans[i] does not have to be distinct ***
for (int v = 1; v <= n; v++) {
int w = (l % v) == 0 ? l : l + v - (l % v);
if (w > r) {
return null;
}
ans[v-1] = w;
myAssert(ans[v-1] <= r && ans[v-1] >= l);
}
return ans;
}
static int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
static void verify(int[] a, int l, int r) {
if (a == null) {
return;
}
int n = a.length;
boolean[] used = new boolean[n+1];
for (int i = 1; i <= n; i++) {
int v = gcd(i, a[i-1]);
if (used[v]) {
System.out.format(" i:%d a[i]:%d v:%d used!\n", i, a[i-1], v);
}
myAssert(!used[v]);
used[v] = true;
}
}
static boolean test = false;
static void doTest() {
if (!test) {
return;
}
long t0 = System.currentTimeMillis();
int n = 10;
for (int t = 0; t < 10; t++) {
int v1 = 1 + RAND.nextInt(999);
int v2 = 1 + RAND.nextInt(999);
int l = Math.min(v1, v2);
int r = Math.max(v1, v2);
System.out.format(" n:%d [%d,%d]\n", n, l, r);
int[] ans = solve(n, l, r);
output(ans);
verify(ans, l, r);
}
System.out.format("%d msec\n", System.currentTimeMillis() - t0);
System.exit(0);
}
public static void main(String[] args) {
doTest();
MyScanner in = new MyScanner();
int T = in.nextInt();
for (int t = 1; t <= T; t++) {
int n = in.nextInt();
int l = in.nextInt();
int r = in.nextInt();
int[] ans = solve(n, l, r);
output(ans);
}
}
static void output(int[] a) {
if (a == null) {
System.out.println("NO");
return;
}
StringBuilder sb = new StringBuilder();
sb.append("YES\n");
for (int v : a) {
sb.append(v);
sb.append(' ');
if (sb.length() > 500) {
System.out.print(sb.toString());
sb.setLength(0);
}
}
System.out.println(sb.toString());
}
static void myAssert(boolean cond) {
if (!cond) {
throw new RuntimeException("Unexpected");
}
}
static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
try {
final String USERDIR = System.getProperty("user.dir");
String cname = MethodHandles.lookup().lookupClass().getCanonicalName().replace(".MyScanner", "");
cname = cname.lastIndexOf('.') > 0 ? cname.substring(cname.lastIndexOf('.') + 1) : cname;
final File fin = new File(USERDIR + "/io/c" + cname.substring(1,5) + "/" + cname + ".in");
br = new BufferedReader(new InputStreamReader(fin.exists()
? new FileInputStream(fin) : System.in));
} catch (Exception e) {
br = new BufferedReader(new InputStreamReader(System.in));
}
}
public String next() {
try {
while (st == null || !st.hasMoreElements()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | a2c724981464322e47b6dd950a3895e9 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class Practice {
static boolean multipleTC = true;
final static int mod = 1000000007;
final static int mod2 = 998244353;
final double E = 2.7182818284590452354;
final double PI = 3.14159265358979323846;
int MAX = 200005;
int N = 40000;
void pre() throws Exception {
}
// All the best
void solve(int TC) throws Exception {
int n = ni();
long l = ni(), r = ni();
long res[] = new long[n + 1];
HashSet<Long> set = new HashSet<>();
for (int i = n; i > 0; i--) {
long firstDivisor = ((l - 1) / i + 1) * i;
if (firstDivisor > r) {
pn("NO");
return;
}
res[i] = firstDivisor;
}
pn("YES");
StringBuilder ans = new StringBuilder();
for (int i = 1; i <= n; i++) {
ans.append(res[i] + " ");
}
pn(ans);
}
double dist(int x1, int y1, int x2, int y2) {
double a = x1 - x2, b = y1 - y2;
return Math.sqrt((a * a) + (b * b));
}
int[] readArr(int n) throws Exception {
int arr[] = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = ni();
}
return arr;
}
void sort(int arr[], int left, int right) {
ArrayList<Integer> list = new ArrayList<>();
for (int i = left; i <= right; i++)
list.add(arr[i]);
Collections.sort(list);
for (int i = left; i <= right; i++)
arr[i] = list.get(i - left);
}
void sort(int arr[]) {
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < arr.length; i++)
list.add(arr[i]);
Collections.sort(list);
for (int i = 0; i < arr.length; i++)
arr[i] = list.get(i);
}
public long max(long... arr) {
long max = arr[0];
for (long itr : arr)
max = Math.max(max, itr);
return max;
}
public int max(int... arr) {
int max = arr[0];
for (int itr : arr)
max = Math.max(max, itr);
return max;
}
public long min(long... arr) {
long min = arr[0];
for (long itr : arr)
min = Math.min(min, itr);
return min;
}
public int min(int... arr) {
int min = arr[0];
for (int itr : arr)
min = Math.min(min, itr);
return min;
}
public long sum(long... arr) {
long sum = 0;
for (long itr : arr)
sum += itr;
return sum;
}
public long sum(int... arr) {
long sum = 0;
for (int itr : arr)
sum += itr;
return sum;
}
String bin(long n) {
return Long.toBinaryString(n);
}
String bin(int n) {
return Integer.toBinaryString(n);
}
static int bitCount(int x) {
return x == 0 ? 0 : (1 + bitCount(x & (x - 1)));
}
static void dbg(Object... o) {
System.err.println(Arrays.deepToString(o));
}
int bit(long n) {
return (n == 0) ? 0 : (1 + bit(n & (n - 1)));
}
int abs(int a) {
return (a < 0) ? -a : a;
}
long abs(long a) {
return (a < 0) ? -a : a;
}
void p(Object o) {
out.print(o);
}
void pn(Object o) {
out.println(o);
}
void pni(Object o) {
out.println(o);
out.flush();
}
void pn(int[] arr) {
int n = arr.length;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
sb.append(arr[i] + " ");
}
pn(sb);
}
void pn(long[] arr) {
int n = arr.length;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
sb.append(arr[i] + " ");
}
pn(sb);
}
String n() throws Exception {
return in.next();
}
String nln() throws Exception {
return in.nextLine();
}
int ni() throws Exception {
return Integer.parseInt(in.next());
}
long nl() throws Exception {
return Long.parseLong(in.next());
}
double nd() throws Exception {
return Double.parseDouble(in.next());
}
public static void main(String[] args) throws Exception {
new Practice().run();
}
FastReader in;
PrintWriter out;
void run() throws Exception {
in = new FastReader();
out = new PrintWriter(System.out);
int T = (multipleTC) ? ni() : 1;
pre();
for (int t = 1; t <= T; t++)
solve(t);
out.flush();
out.close();
}
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws Exception {
br = new BufferedReader(new FileReader(s));
}
String next() throws Exception {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
throw new Exception(e.toString());
}
}
return st.nextToken();
}
String nextLine() throws Exception {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
throw new Exception(e.toString());
}
return str;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | e973b93e328fbcc812be92df93832b9c | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static int mod = 1000000007;
static void read(int arr[], int start, int end, FastReader in) {
for (int i = start; i < end; i++) {
arr[i] = in.nextInt();
}
}
static int sumArr(int arr[]) {
int sum = 0;
for (int i = 0; i < arr.length; i++) {
sum += arr[i];
}
return sum;
}
static final int MAX = 10000000;
static int prefix[] = new int[MAX + 1];
static void buildPrefix() {
// Create a boolean array "prime[0..n]". A
// value in prime[i] will finally be false
// if i is Not a prime, else true.
boolean prime[] = new boolean[MAX + 1];
Arrays.fill(prime, true);
for (int p = 2; p * p <= MAX; p++) {
// If prime[p] is not changed, then
// it is a prime
if (prime[p] == true) {
// Update all multiples of p
for (int i = p * 2; i <= MAX; i += p) {
prime[i] = false;
}
}
}
// Build prefix array
prefix[0] = prefix[1] = 0;
for (int p = 2; p <= MAX; p++) {
prefix[p] = prefix[p - 1];
if (prime[p]) {
prefix[p]++;
}
}
}
static int query(int L, int R) {
return prefix[R] - prefix[L - 1];
}
static int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
static Long gcd(Long a, Long b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
static int min(int arr[]) {
int min = Integer.MAX_VALUE;
for (int i = 0; i < arr.length; i++) {
min = Math.min(min, arr[i]);
}
return min;
}
public static void sort(int[] arr) {
ArrayList<Integer> ls = new ArrayList<>();
for (int x : arr) {
ls.add(x);
}
Collections.sort(ls);
for (int i = 0; i < arr.length; i++) {
arr[i] = ls.get(i);
}
}
public static void sortrev(int[] arr) {
ArrayList<Integer> ls = new ArrayList<>();
for (int x : arr) {
ls.add(x);
}
Collections.sort(ls,Collections.reverseOrder());
for (int i = 0; i < arr.length; i++) {
arr[i] = ls.get(i);
}
}
public static void sort(long[] arr) {
ArrayList<Long> ls = new ArrayList<>();
for (long x : arr) {
ls.add(x);
}
Collections.sort(ls);
for (int i = 0; i < arr.length; i++) {
arr[i] = ls.get(i);
}
}
static int max(int arr[]) {
int max = Integer.MIN_VALUE;
for (int i = 0; i < arr.length; i++) {
max = Math.max(max, arr[i]);
}
return max;
}
static long max(long arr[]) {
long max = Long.MIN_VALUE;
for (int i = 0; i < arr.length; i++) {
max = Math.max(max, arr[i]);
}
return max;
}
static int max(int a, int b) {
return Math.max(a, b);
}
static long max(long a, long b){
return (a>b)?a:b;
}
static int min(int a, int b) {
return Math.min(a, b);
}
static long min(long a, long b){
return Math.min(a, b);
}
public static boolean isPrime(long n) {
if (n < 2) {
return false;
}
if (n == 2 || n == 3) {
return true;
}
if (n % 2 == 0 || n % 3 == 0) {
return false;
}
long sqrtN = (long) Math.sqrt(n) + 1;
for (long i = 6L; i <= sqrtN; i += 6) {
if (n % (i - 1) == 0 || n % (i + 1) == 0) {
return false;
}
}
return true;
}
static class Pair {
int first;
int second;
Pair(int f, int s) {
first = f;
second = s;
}
@Override
public String toString() {
return "first: " + first + " second: " + second;
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
void read(int arr[]) {
for (int i = 0; i < arr.length; i++) {
arr[i] = nextInt();
}
}
void read(long arr[]) {
for (int i = 0; i < arr.length; i++) {
arr[i] = nextLong();
}
}
void read(char arr[][]){
for(int i=0;i<arr.length;i++){
String s=next();
for(int j=0;j<s.length();j++)
arr[i][j]=s.charAt(j);
}
}
void read(Pair arr[]) {
for (int i = 0; i < arr.length; i++) {
int x = nextInt();
int y = nextInt();
arr[i] = new Pair(x, y);
}
}
}
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void println(Object object) throws IOException {
print(object);
bw.append("\n");
}
public void printarr(int arr[]) throws IOException {
println(Arrays.toString(arr));
}
public void printarr(long arr[]) throws IOException {
println(Arrays.toString(arr));
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void close() throws IOException {
bw.close();
}
}
public static int count(String s, char c) {
int count = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == c) {
count++;
}
}
return count;
}
public static int stoi(String s) {
return Integer.parseInt(s);
}
public static String itos(int n) {
return Integer.toString(n);
}
public static int ctoi(char c) {
return (int) c - 48;
}
public static long countSetBits(long n) {
long count = 0;
while (n != 0) {
count += (n & 1); // check last bit
n >>= 1;
}
return count;
}
static long MOD = (long) (1e9 + 7);
static long powerLL(long x, long n) {
long result = 1;
while (n > 0) {
if (n % 2 == 1) {
result = result * x % MOD;
}
n = n / 2;
x = x * x % MOD;
}
return result;
}
static long countBits(long number) {
return (long) (Math.log(number)
/ Math.log(2) + 1);
}
static boolean isPowerOfTwo(long n) {
if (n == 0) {
return false;
}
while (n != 1) {
if (n % 2 != 0) {
return false;
}
n = n / 2;
}
return true;
}
public static int LCS(String s1, String s2){
int l1=s1.length();
int l2=s2.length();
int dp[][]=new int[l1+1][l2+1];
for(int i=0;i<=l1;i++){
for(int j=0;j<=l2;j++){
if(i==0 || j==0)
dp[i][j]=0;
else{
if(s1.charAt(i-1)==s2.charAt(j-1))
dp[i][j]=1+dp[i-1][j-1];
else
dp[i][j]=Math.max(dp[i-1][j], dp[i][j-1]);
}
}
}
// for(var v:dp)
// System.out.println(Arrays.toString(v));
return dp[l1][l2];
}
public static String LCSstring(String s1, String s2){
int l1=s1.length();
int l2=s2.length();
int dp[][]=new int[l1+1][l2+1];
for(int i=0;i<=l1;i++){
for(int j=0;j<=l2;j++){
if(i==0 || j==0)
dp[i][j]=0;
else{
if(s1.charAt(i-1)==s2.charAt(j-1))
dp[i][j]=1+dp[i-1][j-1];
else
dp[i][j]=Math.max(dp[i-1][j], dp[i][j-1]);
}
}
}
String ans="";
int i=l1,j=l2;
while(i>0 && j>0){
if(s1.charAt(i-1)==s2.charAt(j-1)){
ans=s1.charAt(i-1)+ans;
i--;
j--;
}
else if(dp[i-1][j]>dp[i][j-1]){
i--;
}
else
j--;
}
return ans;
}
public static int factorial(int n)
{
return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
public static int nCr(int n, int r,int a) {
return factorial(n) / (factorial(r) * factorial(n - r));
}
public static boolean[] sieve()
{
int n=10000000;
// Create a boolean array
// "prime[0..n]" and
// initialize all entries
// it as true. A value in
// prime[i] will finally be
// false if i is Not a
// prime, else true.
boolean prime[] = new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++)
{
// If prime[p] is not changed, then it is a
// prime
if (prime[p] == true)
{
// Update all multiples of p
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
return prime;
}
static int maxSubArraySum(int a[])
{
int size = a.length;
int max_so_far = Integer.MIN_VALUE, max_ending_here = 0;
for (int i = 0; i < size; i++)
{
max_ending_here = max_ending_here + a[i];
if (max_so_far < max_ending_here)
max_so_far = max_ending_here;
if (max_ending_here < 0)
max_ending_here = 0;
}
return max_so_far;
}
public static int calc(int arr[],int n){
if(n<0 || n<arr[0])
return 0;
if(n>=arr[2])
return max(max(1+calc(arr,n-arr[2]),1+calc(arr,n-arr[1])),1+calc(arr,n-arr[0]));
else if(n>=arr[1])
return max(1+calc(arr,n-arr[1]),1+calc(arr,n-arr[0]));
else if(n>=arr[0])
return 1+calc(arr,n-arr[0]);
else
return 0;
}
static int dp[];
public static int calc(int n, int org){
if(n==org)
return 0;
else if(n>org)
return 99999;
if(dp[n]!=-1)
return dp[n];
return dp[n]=Math.min(1+calc(n+1,org) , 1+calc(2*n,org));
}
public static int minOperation(int n)
{
dp=new int[n+1];
for(int i=0;i<=n;i++)
dp[i]=-1;
int ans=calc(1,n);
return ans+1;
}
static int nCr(int n, int r)
{
int mod=1000000007;
if(r>n)
return 0;
int dp[][]=new int[n+1][n+1];
dp[0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=i;j++){
if(j==0 || j==i)
dp[i][j]=1;
else
dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%mod;
}
}
return dp[n][r];
}
public static int calc(String s1, String s2){
int arr1[]=new int[26];
int arr2[]=new int[26];
for(char c:s1.toCharArray())
arr1[c-'a']++;
for(char c:s2.toCharArray())
arr2[c-'a']++;
int sum=0;
for(int i=0;i<26;i++)
sum+=((arr2[i]-arr1[i])>0)?(arr2[i]-arr1[i]):0;
return sum;
}
public static boolean isSorted(int arr[]){
int sor[]=new int[arr.length];
for(int i=0;i<arr.length;i++)
sor[i]=arr[i];
sort(sor);
boolean check=true;
for(int i=0;i<arr.length;i++){
if(sor[i]!=arr[i]){
check=false;
break;
}
}
return check;
}
public static int find(int arr[], int n){
for(int i=0;i<arr.length;i++)
if(arr[i]==n)
return i;
return -1;
}
public static long calc(long n,long m, long mid,long k){
long ans=0;
for(int i=1;i<=n;i++)
ans+=Math.min(mid/i,m);
return ans;
}
public static boolean check(int arr[],int k){
int count=0;
for(int i=0;i<arr.length;i++)
if(arr[i]%(i+1) == 0)
count++;
return count==k;
}
static int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
static long lcm(long a, long b){
return (a/gcd(a,b))*b;
}
static int limit=1000000;
public static boolean same(String s){
boolean check=true;
for(int i=1;i<s.length();i++){
if(s.charAt(i)!=s.charAt(i-1)){
check=false;
break;
}
}
return check;
}
static int limit1=1000000000;
public static void printCount(int arr[],FastWriter out){
try{
for(int p:arr)
out.print(p+" ");
out.println("");
}
catch ( Exception E){
}
}
public static class item{
int len;
int cost;
item(int l, int c){
len=l;
cost=c;
}
@Override
public String toString() {
return "len: " + len + " cost: " + cost;
}
}
public static class comparator implements Comparator<item>{
public int compare(item i, item j){
if(i.len*i.cost != j.len*j.cost)
return (-(i.len*i.cost - j.len*j.cost));
else
return (-(i.len-j.len));
}
}
public static void cpy(int arr1[],int arr2[]){
for(int i=0;i<arr1.length;i++)
arr2[i]=arr1[i];
}
static int UpperBound(ArrayList<Integer> a, int x) {// x is the key or target value
int l=-1,r=a.size();
while(l+1<r) {
int m=(l+r)>>>1;
if(a.get(m)<=x) l=m;
else r=m;
}
return l+1;
}
static int LowerBound(ArrayList<Integer> a, int x) { // x is the target value or key
int l=-1,r=a.size();
while(l+1<r) {
int m=(l+r)>>>1;
if(a.get(m)>=x) r=m;
else l=m;
}
return r-1;
}
static int binarySearch(ArrayList<Integer> arr, int x)
{
int left = 0, right = arr.size() - 1;
while (left <= right)
{
int mid = left + (right - left) / 2;
// Check if x is present at mid
if (arr.get(mid) == x)
return mid;
// If x greater, ignore left half
if (arr.get(mid) < x)
left = mid + 1;
// If x is smaller, ignore right half
else
right = mid - 1;
}
// if we reach here, then element was
// not present
return -1;
}
static int upper_bound(ArrayList<Integer> arr, int key)
{
int upperBound = 0;
while (upperBound < arr.size()) {
// If current value is lesser than or equal to
// key
if (arr.get(upperBound) <= key)
upperBound++;
// This value is just greater than key
else{
// System.out.print("The upper bound of " + key + " is " + arr[upperBound] + " at index " + upperBound);
return upperBound;
}
}
return -1;
// System.out.print("The upper bound of " + key + " does not exist.");
}
public static void solve(FastReader in,FastWriter out){
try{
//-----------------------------------------
int n=in.nextInt();
int l=in.nextInt();
int r=in.nextInt();
int arr[]=new int[n];
for(int i=1;i<=n;i++){
if(l%i == 0)
arr[i-1]=l;
else{
int temp=(l/i + 1)*i;
if(temp>r){
out.println("NO");
return;
}
arr[i-1]=temp;
}
}
out.println("YES");
for(int i=0;i<n;i++)
out.print(arr[i]+" ");
out.println("");
//-----------------------------------------
}
catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
// System.out.println(Long.MAX_VALUE-Math.pow(10, 18));
FastReader in = new FastReader();
FastWriter out = new FastWriter();
int tc=1;
tc=in.nextInt();
while(tc-- != 0)
solve(in,out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 02a48401013c5457d4f34cfa806101e2 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class x {
public static void main(String[] args)throws IOException{
Scanner obj = new Scanner(System.in);
int tt = obj.nextInt();
while(tt-->0){
int n = obj.nextInt();
int l = obj.nextInt();
int r = obj.nextInt();
solve(n,l,r);
}
}
static void solve(int n,int l,int r){
List<Integer> list = new ArrayList<>();
for(int i=1;i<=n;i++){
if(r/i*i<l){
System.out.println("NO");
return;
}
list.add(r/i*i);
}
System.out.println("YES");
for(int i=0;i<list.size();i++){
System.out.print(list.get(i)+" ");
}
System.out.println();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | b118b1df6557f3a67791303eb6e32bac | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class y {
public static void main(String[] args)throws IOException{
Scanner obj = new Scanner(System.in);
int t = obj.nextInt();
while(t-->0){
int n = obj.nextInt();
int l = obj.nextInt();
int r = obj.nextInt();
boolean b = true;
ArrayList<Integer> list = new ArrayList<>();
for(int i = 1;i<=n;i++){
if(l%i == 0){
list.add(l);
}
else{
int tt = i - l%i+l;
if(tt<l || tt >r){
b = false;
break;
}
list.add(tt);
}
}
if(b){
System.out.println("YES");
for(int i=0;i<n;i++){
System.out.print(list.get(i)+ " ");
}
System.out.println();
}
else{
System.out.println("NO");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | bfc03eeb9a14eb4537d5f4e702718a30 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | // JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.*;
import java.lang.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.io.*;
public class CodeForces {
static private final String INPUT = "input.txt";
static private final String OUTPUT = "output.txt";
static BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer ST;
static PrintWriter out = new PrintWriter(System.out);
static DecimalFormat df = new DecimalFormat("0.00000");
final static int MAX = Integer.MAX_VALUE, MIN = Integer.MIN_VALUE, mod = (int) (1e9 + 7);
final static long LMAX = Long.MAX_VALUE, LMIN = Long.MIN_VALUE;
final static long INF = (long) 1e18, Neg_INF = (long) -1e18;
static Random rand = new Random();
// ======================= MAIN ==================================
public static void main(String[] args) throws IOException {
long time = System.currentTimeMillis();
boolean oj = System.getProperty("ONLINE_JUDGE") != null;
// ==== start ====
input();
preprocess();
int t = 1;
t = readInt();
while (t-- > 0) {
solve();
}
out.flush();
// ==== end ====
if (!oj)
System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
}
private static void solve() throws IOException {
int n = readInt(), l = readInt(), r = readInt();
int[] arr = new int[n];
for (int i = 1; i <= n; i++) {
arr[i - 1] = ((int) Math.ceil(1.0 * l / i)) * i;
if (arr[i - 1] > r) {
no();
return;
}
}
yes();
printIArray(arr);
}
private static void preprocess() throws IOException {
}
// cd C:\Users\Eshan Bhatt\Visual Studio Code\Competitive Programming\CodeForces
// javac CodeForces.java && java CodeForces
// change Stack size -> java -Xss16M CodeForces.java
// ==================== CUSTOM CLASSES ================================
static class Pair implements Comparable<Pair> {
int first, second;
Pair(int f, int s) {
first = f;
second = s;
}
public int compareTo(Pair o) {
if (this.first == o.first)
return this.second - o.second;
return this.first - o.first;
}
@Override
public boolean equals(Object obj) {
if (obj == this)
return true;
if (obj == null)
return false;
if (this.getClass() != obj.getClass())
return false;
Pair other = (Pair) (obj);
if (this.first != other.first)
return false;
if (this.second != other.second)
return false;
return true;
}
@Override
public int hashCode() {
return this.first ^ this.second;
}
@Override
public String toString() {
return this.first + " " + this.second;
}
}
static class DequeNode {
DequeNode prev, next;
int val;
DequeNode(int val) {
this.val = val;
}
DequeNode(int val, DequeNode prev, DequeNode next) {
this.val = val;
this.prev = prev;
this.next = next;
}
}
// ======================= FOR INPUT ==================================
private static void input() {
FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
System.err.println("Error Occurred.");
}
BR = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
}
static String next() throws IOException {
while (ST == null || !ST.hasMoreTokens())
ST = new StringTokenizer(readLine());
return ST.nextToken();
}
static long readLong() throws IOException {
return Long.parseLong(next());
}
static int readInt() throws IOException {
return Integer.parseInt(next());
}
static double readDouble() throws IOException {
return Double.parseDouble(next());
}
static char readCharacter() throws IOException {
return next().charAt(0);
}
static String readString() throws IOException {
return next();
}
static String readLine() throws IOException {
return BR.readLine().trim();
}
static int[] readIntArray(int n) throws IOException {
int[] arr = new int[n];
for (int i = 0; i < n; i++)
arr[i] = readInt();
return arr;
}
static int[][] read2DIntArray(int n, int m) throws IOException {
int[][] arr = new int[n][m];
for (int i = 0; i < n; i++)
arr[i] = readIntArray(m);
return arr;
}
static List<Integer> readIntList(int n) throws IOException {
List<Integer> list = new ArrayList<>(n);
for (int i = 0; i < n; i++)
list.add(readInt());
return list;
}
static long[] readLongArray(int n) throws IOException {
long[] arr = new long[n];
for (int i = 0; i < n; i++)
arr[i] = readLong();
return arr;
}
static long[][] read2DLongArray(int n, int m) throws IOException {
long[][] arr = new long[n][m];
for (int i = 0; i < n; i++)
arr[i] = readLongArray(m);
return arr;
}
static List<Long> readLongList(int n) throws IOException {
List<Long> list = new ArrayList<>(n);
for (int i = 0; i < n; i++)
list.add(readLong());
return list;
}
static char[] readCharArray() throws IOException {
return readString().toCharArray();
}
static char[][] readMatrix(int n, int m) throws IOException {
char[][] mat = new char[n][m];
for (int i = 0; i < n; i++)
mat[i] = readCharArray();
return mat;
}
// ========================= FOR OUTPUT ==================================
private static void printIList(List<Integer> list) {
for (int i = 0; i < list.size(); i++)
out.print(list.get(i) + " ");
out.println(" ");
}
private static void printLList(List<Long> list) {
for (int i = 0; i < list.size(); i++)
out.print(list.get(i) + " ");
out.println(" ");
}
private static void printIArray(int[] arr) {
for (int i = 0; i < arr.length; i++)
out.print(arr[i] + " ");
out.println(" ");
}
private static void print2DIArray(int[][] arr) {
for (int i = 0; i < arr.length; i++)
printIArray(arr[i]);
}
private static void printLArray(long[] arr) {
for (int i = 0; i < arr.length; i++)
out.print(arr[i] + " ");
out.println(" ");
}
private static void print2DLArray(long[][] arr) {
for (int i = 0; i < arr.length; i++)
printLArray(arr[i]);
}
private static void yes() {
out.println("YES");
}
private static void no() {
out.println("NO");
}
// ====================== TO CHECK IF STRING IS NUMBER ========================
private static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException e) {
return false;
} catch (NullPointerException e) {
return false;
}
return true;
}
private static boolean isLong(String s) {
try {
Long.parseLong(s);
} catch (NumberFormatException e) {
return false;
} catch (NullPointerException e) {
return false;
}
return true;
}
// ==================== FASTER SORT ================================
private static void sort(int[] arr) {
int n = arr.length;
List<Integer> list = new ArrayList<>(n);
for (int i = 0; i < n; i++)
list.add(arr[i]);
Collections.sort(list);
for (int i = 0; i < n; i++)
arr[i] = list.get(i);
}
private static void reverseSort(int[] arr) {
int n = arr.length;
List<Integer> list = new ArrayList<>(n);
for (int i = 0; i < n; i++)
list.add(arr[i]);
Collections.sort(list, Collections.reverseOrder());
for (int i = 0; i < n; i++)
arr[i] = list.get(i);
}
private static void sort(long[] arr) {
int n = arr.length;
List<Long> list = new ArrayList<>(n);
for (int i = 0; i < n; i++)
list.add(arr[i]);
Collections.sort(list);
for (int i = 0; i < n; i++)
arr[i] = list.get(i);
}
private static void reverseSort(long[] arr) {
int n = arr.length;
List<Long> list = new ArrayList<>(n);
for (int i = 0; i < n; i++)
list.add(arr[i]);
Collections.sort(list, Collections.reverseOrder());
for (int i = 0; i < n; i++)
arr[i] = list.get(i);
}
// ==================== MATHEMATICAL FUNCTIONS ===========================
private static int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
private static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
private static int lcm(int a, int b) {
return (a / gcd(a, b)) * b;
}
private static long lcm(long a, long b) {
return (a / gcd(a, b)) * b;
}
private static int mod_pow(long a, long b, int mod) {
if (b == 0)
return 1;
int temp = mod_pow(a, b >> 1, mod);
temp %= mod;
temp = (int) ((1L * temp * temp) % mod);
if ((b & 1) == 1)
temp = (int) ((1L * temp * a) % mod);
return temp;
}
private static long multiply(long a, long b) {
return (((a % mod) * (b % mod)) % mod);
}
private static long divide(long a, long b) {
return multiply(a, mod_pow(b, mod - 2, mod));
}
private static boolean isPrime(long n) {
for (long i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return true;
}
private static long nCr(long n, long r) {
if (n - r > r)
r = n - r;
long ans = 1L;
for (long i = r + 1; i <= n; i++)
ans *= i;
for (long i = 2; i <= n - r; i++)
ans /= i;
return ans;
}
private static List<Integer> factors(int n) {
List<Integer> list = new ArrayList<>();
for (int i = 1; 1L * i * i <= n; i++)
if (n % i == 0) {
list.add(i);
if (i != n / i)
list.add(n / i);
}
return list;
}
private static List<Long> factors(long n) {
List<Long> list = new ArrayList<>();
for (long i = 1; i * i <= n; i++)
if (n % i == 0) {
list.add(i);
if (i != n / i)
list.add(n / i);
}
return list;
}
// ==================== Primes using Seive =====================
private static List<Integer> getPrimes(int n) {
boolean[] prime = new boolean[n + 1];
Arrays.fill(prime, true);
for (int i = 2; 1L * i * i <= n; i++)
if (prime[i])
for (int j = i * i; j <= n; j += i)
prime[j] = false;
// return prime;
List<Integer> list = new ArrayList<>();
for (int i = 2; i <= n; i++)
if (prime[i])
list.add(i);
return list;
}
private static int[] SeivePrime(int n) {
int[] primes = new int[n];
for (int i = 0; i < n; i++)
primes[i] = i;
for (int i = 2; 1L * i * i < n; i++) {
if (primes[i] != i)
continue;
for (int j = i * i; j < n; j += i)
if (primes[j] == j)
primes[j] = i;
}
return primes;
}
// ==================== STRING FUNCTIONS ================================
private static boolean isPalindrome(String str) {
int i = 0, j = str.length() - 1;
while (i < j)
if (str.charAt(i++) != str.charAt(j--))
return false;
return true;
}
// check if a is subsequence of b
private static boolean isSubsequence(String a, String b) {
int idx = 0;
for (int i = 0; i < b.length() && idx < a.length(); i++)
if (a.charAt(idx) == b.charAt(i))
idx++;
return idx == a.length();
}
private static String reverseString(String str) {
StringBuilder sb = new StringBuilder(str);
return sb.reverse().toString();
}
private static String sortString(String str) {
int[] arr = new int[256];
for (char ch : str.toCharArray())
arr[ch]++;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 256; i++)
while (arr[i]-- > 0)
sb.append((char) i);
return sb.toString();
}
// ==================== LIS & LNDS ================================
private static int LIS(int arr[], int n) {
List<Integer> list = new ArrayList<>();
for (int i = 0; i < n; i++) {
int idx = find1(list, arr[i]);
if (idx < list.size())
list.set(idx, arr[i]);
else
list.add(arr[i]);
}
return list.size();
}
private static int find1(List<Integer> list, int val) {
int ret = list.size(), i = 0, j = list.size() - 1;
while (i <= j) {
int mid = (i + j) / 2;
if (list.get(mid) >= val) {
ret = mid;
j = mid - 1;
} else {
i = mid + 1;
}
}
return ret;
}
private static int LNDS(int[] arr, int n) {
List<Integer> list = new ArrayList<>();
for (int i = 0; i < n; i++) {
int idx = find2(list, arr[i]);
if (idx < list.size())
list.set(idx, arr[i]);
else
list.add(arr[i]);
}
return list.size();
}
private static int find2(List<Integer> list, int val) {
int ret = list.size(), i = 0, j = list.size() - 1;
while (i <= j) {
int mid = (i + j) / 2;
if (list.get(mid) <= val) {
i = mid + 1;
} else {
ret = mid;
j = mid - 1;
}
}
return ret;
}
// =============== Lower Bound & Upper Bound ===========
// less than or equal
private static int lower_bound(List<Integer> list, int val) {
int ans = -1, lo = 0, hi = list.size() - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (list.get(mid) <= val) {
ans = mid;
lo = mid + 1;
} else {
hi = mid - 1;
}
}
return ans;
}
private static int lower_bound(List<Long> list, long val) {
int ans = -1, lo = 0, hi = list.size() - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (list.get(mid) <= val) {
ans = mid;
lo = mid + 1;
} else {
hi = mid - 1;
}
}
return ans;
}
private static int lower_bound(int[] arr, int val) {
int ans = -1, lo = 0, hi = arr.length - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (arr[mid] <= val) {
ans = mid;
lo = mid + 1;
} else {
hi = mid - 1;
}
}
return ans;
}
private static int lower_bound(long[] arr, long val) {
int ans = -1, lo = 0, hi = arr.length - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (arr[mid] <= val) {
ans = mid;
lo = mid + 1;
} else {
hi = mid - 1;
}
}
return ans;
}
// greater than or equal
private static int upper_bound(List<Integer> list, int val) {
int ans = list.size(), lo = 0, hi = ans - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (list.get(mid) >= val) {
ans = mid;
hi = mid - 1;
} else {
lo = mid + 1;
}
}
return ans;
}
private static int upper_bound(List<Long> list, long val) {
int ans = list.size(), lo = 0, hi = ans - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (list.get(mid) >= val) {
ans = mid;
hi = mid - 1;
} else {
lo = mid + 1;
}
}
return ans;
}
private static int upper_bound(int[] arr, int val) {
int ans = arr.length, lo = 0, hi = ans - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (arr[mid] >= val) {
ans = mid;
hi = mid - 1;
} else {
lo = mid + 1;
}
}
return ans;
}
private static int upper_bound(long[] arr, long val) {
int ans = arr.length, lo = 0, hi = ans - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (arr[mid] >= val) {
ans = mid;
hi = mid - 1;
} else {
lo = mid + 1;
}
}
return ans;
}
// ==================== UNION FIND =====================
private static int find(int x, int[] parent) {
if (parent[x] == x)
return x;
return parent[x] = find(parent[x], parent);
}
private static boolean union(int x, int y, int[] parent, int[] rank) {
int lx = find(x, parent), ly = find(y, parent);
if (lx == ly)
return false;
if (rank[lx] > rank[ly])
parent[ly] = lx;
else if (rank[lx] < rank[ly])
parent[lx] = ly;
else {
parent[lx] = ly;
rank[ly]++;
}
return true;
}
// ==================== TRIE ================================
static class Trie {
class Node {
Node[] children;
boolean isEnd;
Node() {
children = new Node[26];
}
}
Node root;
Trie() {
root = new Node();
}
void insert(String word) {
Node curr = root;
for (char ch : word.toCharArray()) {
if (curr.children[ch - 'a'] == null)
curr.children[ch - 'a'] = new Node();
curr = curr.children[ch - 'a'];
}
curr.isEnd = true;
}
boolean find(String word) {
Node curr = root;
for (char ch : word.toCharArray()) {
if (curr.children[ch - 'a'] == null)
return false;
curr = curr.children[ch - 'a'];
}
return curr.isEnd;
}
}
// ================== SEGMENT TREE (RANGE SUM & RANGE UPDATE) ==================
public static class SegmentTree {
int n;
long[] arr, tree, lazy;
SegmentTree(long arr[]) {
this.arr = arr;
this.n = arr.length;
this.tree = new long[(n << 2)];
this.lazy = new long[(n << 2)];
build(1, 0, n - 1);
}
void build(int id, int start, int end) {
if (start == end)
tree[id] = arr[start];
else {
int mid = (start + end) / 2, left = (id << 1), right = left + 1;
build(left, start, mid);
build(right, mid + 1, end);
tree[id] = tree[left] + tree[right];
}
}
void update(int l, int r, long val) {
update(1, 0, n - 1, l, r, val);
}
void update(int id, int start, int end, int l, int r, long val) {
distribute(id, start, end);
if (end < l || r < start)
return;
if (start == end)
tree[id] += val;
else if (l <= start && end <= r) {
lazy[id] += val;
distribute(id, start, end);
} else {
int mid = (start + end) / 2, left = (id << 1), right = left + 1;
update(left, start, mid, l, r, val);
update(right, mid + 1, end, l, r, val);
tree[id] = tree[left] + tree[right];
}
}
long query(int l, int r) {
return query(1, 0, n - 1, l, r);
}
long query(int id, int start, int end, int l, int r) {
if (end < l || r < start)
return 0L;
distribute(id, start, end);
if (start == end)
return tree[id];
else if (l <= start && end <= r)
return tree[id];
else {
int mid = (start + end) / 2, left = (id << 1), right = left + 1;
return query(left, start, mid, l, r) + query(right, mid + 1, end, l, r);
}
}
void distribute(int id, int start, int end) {
if (start == end)
tree[id] += lazy[id];
else {
tree[id] += lazy[id] * (end - start + 1);
lazy[(id << 1)] += lazy[id];
lazy[(id << 1) + 1] += lazy[id];
}
lazy[id] = 0;
}
}
// ==================== FENWICK TREE ================================
static class FT {
int n;
int[] arr;
int[] tree;
FT(int[] arr, int n) {
this.arr = arr;
this.n = n;
this.tree = new int[n + 1];
for (int i = 1; i <= n; i++) {
update(i, arr[i - 1]);
}
}
FT(int n) {
this.n = n;
this.tree = new int[n + 1];
}
// 1 based indexing
void update(int idx, int val) {
while (idx <= n) {
tree[idx] += val;
idx += idx & -idx;
}
}
// 1 based indexing
int query(int l, int r) {
return getSum(r) - getSum(l - 1);
}
int getSum(int idx) {
int ans = 0;
while (idx > 0) {
ans += tree[idx];
idx -= idx & -idx;
}
return ans;
}
}
// ==================== BINARY INDEX TREE ================================
static class BIT {
long[][] tree;
int n, m;
BIT(int[][] mat, int n, int m) {
this.n = n;
this.m = m;
tree = new long[n + 1][m + 1];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
update(i, j, mat[i - 1][j - 1]);
}
}
}
void update(int x, int y, int val) {
while (x <= n) {
int t = y;
while (t <= m) {
tree[x][t] += val;
t += t & -t;
}
x += x & -x;
}
}
long query(int x1, int y1, int x2, int y2) {
return getSum(x2, y2) - getSum(x1 - 1, y2) - getSum(x2, y1 - 1) + getSum(x1 - 1, y1 - 1);
}
long getSum(int x, int y) {
long ans = 0L;
while (x > 0) {
int t = y;
while (t > 0) {
ans += tree[x][t];
t -= t & -t;
}
x -= x & -x;
}
return ans;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 0de8794aab5cc875479470c2614bb1a6 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class B {
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-->0)
{
StringBuilder sb = new StringBuilder();
int n = s.nextInt(), l = s.nextInt(), r = s.nextInt();
//long a[] = new long[n];
ArrayList<Long> a = new ArrayList<Long>();
boolean ans = true;
for(int i=1; i<=n; i++)
{
if(((l-1)/i+1)*i<=r) sb.append(((l-1)/i+1)*i + " ");
else
{
ans = false;
break;
}
}
if(ans) System.out.println("Yes\n" + sb.toString());
else System.out.println("No");
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | b9312bdb9b9316f90f76f5e78049264d | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | //package com.rajan.codeforces.contests.contest808;
import java.io.*;
public class ProblemB {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
int tt = Integer.parseInt(reader.readLine());
while (tt-- > 0) {
int[] input = parseInt(reader.readLine(), 3);
int n = input[0], l = input[1], r = input[2];
long[] a = new long[n + 1];
boolean ok = true;
for (int idx = 1; idx <= n && ok; idx++) {
a[idx] = ((l - 1L) / idx + 1L) * 1L * idx;
ok = ok && a[idx] <= r;
}
if (!ok) {
writer.write("NO\n");
} else {
writer.write("YES\n");
boolean first = true;
for (int i = 1; i <= n; i++) {
writer.write((first ? "" : " ") + a[i]);
first = false;
}
writer.write("\n");
}
}
writer.flush();
}
private static int[] parseInt(String str, int n) {
int[] ans = new int[n];
int idx = 0;
for (int k = 0; k < str.length(); ) {
int j = k;
int sum = 0;
while (j < str.length() && str.charAt(j) != ' ') {
if (str.charAt(j) == '-') {
j++;
continue;
}
sum = sum * 10 + str.charAt(j) - '0';
j++;
}
ans[idx++] = (str.charAt(k) == '-' ? -1 : 1) * sum;
k = j + 1;
}
return ans;
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 3920e6df3af099d56ea648912785918a | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Solution {
public static int gcd(int a, int b) {
if(a==b) {
return a;
}
else if (a<b) {
for(int i = a; i>=1; i++) {
if(a%i == 0 && b%i==0) {
return i;
}
}
}
else {
for(int i = b; i>=1; i++) {
if(a%i == 0 && b%i==0) {
return i;
}
}
}
return 1;
}
public static void main(String[] args) throws IOException {
Reader r = new Reader();
BufferedWriter o = new BufferedWriter(new OutputStreamWriter(System.out));
int t = r.readI();
outer: for(int z = 1; z<=t; z++){
int[] in = r.readArrI();
int n = in[0];
int l = in[1];
int e = in[2];
int[] a = new int[n+1];
for(int i=1; i<=n; i++) {
if(l%i==0) {
a[i] = l;
}
else {
a[i] = l + i - l%i;
if(a[i]>e) {
o.write("NO\n");
o.flush();
continue outer;
}
}
}
o.write("YES\n");
for(int i = 1; i<=n; i++) {
o.write(a[i] + " ");
}
o.write("\n");
o.flush();
}
}
}
class Reader {
BufferedReader r;
Reader(){
r = new BufferedReader(new InputStreamReader(System.in));
}
public int[] readArrI() throws IOException {
String[] s = r.readLine().split(" ");
int n = s.length;
int[] a = new int[n];
for(int j=0; j<n;j++) {
a[j] = Integer.parseInt(s[j]);
}
return a;
}
public long[] readArrL() throws IOException {
String[] s = r.readLine().split(" ");
int n = s.length;
long[] a = new long[n];
for(int j=0; j<n;j++) {
a[j] = Long.parseLong(s[j]);
}
return a;
}
public int readI() throws IOException {
String[] s = r.readLine().split(" ");
int n = Integer.parseInt(s[0]);
return n;
}
public long readL() throws IOException {
String[] s = r.readLine().split(" ");
long n = Long.parseLong(s[0]);
return n;
}
public String readS() throws IOException {
String s = r.readLine();
return s;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | f5b285721e4464e29dfd8a6c3b5519b2 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static BufferedReader bf;
static PrintWriter out;
static Scanner sc;
static StringTokenizer st;
static long mod = (long)(1e9+7);
static long mod2 = 998244353;
static long fact[] = new long[1000001];
static long inverse[] = new long[1000001];
public static void main (String[] args)throws IOException {
bf = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
sc = new Scanner(System.in);
// fact[0] = 1;
// inverse[0] = 1;
// for(int i = 1;i<fact.length;i++){
// fact[i] = (fact[i-1] * i)%mod;
// // inverse[i] = binaryExpo(fact[i], mod-2);
// }
int t = nextInt();
while(t-->0){
solve();
}
}
public static void solve() throws IOException{
int n = nextInt();
int l = nextInt();
int r = nextInt();
long[]ans = new long[n+1];
for(long i = 1;i<=n;i++){
long left = 1;
long right = (long)(1e9);
boolean check = false;
while(left <= right){
long mid = left + (right - left)/2;
if(mid * i < l){
left = mid+1;
}
else if(mid * i > r){
right = mid-1;
}
else {
ans[(int)i] = mid * i;
check = true;
break;
}
}
if(!check){
println("NO");
return;
}
}
out.println("YES");
for(int i = 1;i<=n;i++){
out.print(ans[i] + " ");
}
out.println();
out.flush();
}
public static long nck(int n,int k){
return fact[n] * inverse[n-k] %mod * inverse[k]%mod;
}
public static void plus(int node,int low,int high,int tlow,int thigh,int[]tree){
if(low >= tlow && high <= thigh){
tree[node]++;
return;
}
if(high < tlow || low > thigh)return;
int mid = (low + high)/2;
plus(node*2,low,mid,tlow,thigh,tree);
plus(node*2 + 1 , mid + 1, high,tlow, thigh,tree);
}
public static boolean allEqual(int[]arr,int x){
for(int i = 0;i<arr.length;i++){
if(arr[i] != x)return false;
}
return true;
}
public static long helper(StringBuilder sb){
return Long.parseLong(sb.toString());
}
public static int min(int node,int low,int high,int tlow,int thigh,int[][]tree){
if(low >= tlow&& high <= thigh)return tree[node][0];
if(high < tlow || low > thigh)return Integer.MAX_VALUE;
int mid = (low + high)/2;
// println(low+" "+high+" "+tlow+" "+thigh);
return Math.min(min(node*2,low,mid,tlow,thigh,tree) ,min(node*2+1,mid+1,high,tlow,thigh,tree));
}
public static int max(int node,int low,int high,int tlow,int thigh,int[][]tree){
if(low >= tlow && high <= thigh)return tree[node][1];
if(high < tlow || low > thigh)return Integer.MIN_VALUE;
int mid = (low + high)/2;
return Math.max(max(node*2,low,mid,tlow,thigh,tree) ,max(node*2+1,mid+1,high,tlow,thigh,tree));
}
public static long[] help(List<List<Integer>>list,int[][]range,int cur){
List<Integer>temp = list.get(cur);
if(temp.size() == 0)return new long[]{range[cur][1],1};
long sum = 0;
long count = 0;
for(int i = 0;i<temp.size();i++){
long []arr = help(list,range,temp.get(i));
sum += arr[0];
count += arr[1];
}
if(sum < range[cur][0]){
count++;
sum = range[cur][1];
}
return new long[]{sum,count};
}
public static long findSum(int node,int low, int high,int tlow,int thigh,long[]tree,long mod){
if(low >= tlow && high <= thigh)return tree[node]%mod;
if(low > thigh || high < tlow)return 0;
int mid = (low + high)/2;
return((findSum(node*2,low,mid,tlow,thigh,tree,mod) % mod) + (findSum(node*2+1,mid+1,high,tlow,thigh,tree,mod)))%mod;
}
public static boolean allzero(long[]arr){
for(int i =0 ;i<arr.length;i++){
if(arr[i]!=0)return false;
}
return true;
}
public static long count(long[][]dp,int i,int[]arr,int drank,long sum){
if(i == arr.length)return 0;
if(dp[i][drank]!=-1 && arr[i]+sum >=0)return dp[i][drank];
if(sum + arr[i] >= 0){
long count1 = 1 + count(dp,i+1,arr,drank+1,sum+arr[i]);
long count2 = count(dp,i+1,arr,drank,sum);
return dp[i][drank] = Math.max(count1,count2);
}
return dp[i][drank] = count(dp,i+1,arr,drank,sum);
}
public static void help(int[]arr,char[]signs,int l,int r){
if( l < r){
int mid = (l+r)/2;
help(arr,signs,l,mid);
help(arr,signs,mid+1,r);
merge(arr,signs,l,mid,r);
}
}
public static void merge(int[]arr,char[]signs,int l,int mid,int r){
int n1 = mid - l + 1;
int n2 = r - mid;
int[]a = new int[n1];
int []b = new int[n2];
char[]asigns = new char[n1];
char[]bsigns = new char[n2];
for(int i = 0;i<n1;i++){
a[i] = arr[i+l];
asigns[i] = signs[i+l];
}
for(int i = 0;i<n2;i++){
b[i] = arr[i+mid+1];
bsigns[i] = signs[i+mid+1];
}
int i = 0;
int j = 0;
int k = l;
boolean opp = false;
while(i<n1 && j<n2){
if(a[i] <= b[j]){
arr[k] = a[i];
if(opp){
if(asigns[i] == 'R'){
signs[k] = 'L';
}
else{
signs[k] = 'R';
}
}
else{
signs[k] = asigns[i];
}
i++;
k++;
}
else{
arr[k] = b[j];
int times = n1 - i;
if(times%2 == 1){
if(bsigns[j] == 'R'){
signs[k] = 'L';
}
else{
signs[k] = 'R';
}
}
else{
signs[k] = bsigns[j];
}
j++;
opp = !opp;
k++;
}
}
while(i<n1){
arr[k] = a[i];
if(opp){
if(asigns[i] == 'R'){
signs[k] = 'L';
}
else{
signs[k] = 'R';
}
}
else{
signs[k] = asigns[i];
}
i++;
k++;
}
while(j<n2){
arr[k] = b[j];
signs[k] = bsigns[j];
j++;
k++;
}
}
public static long binaryExpo(long base,long expo){
if(expo == 0)return 1;
long val;
if(expo%2 == 1){
val = (binaryExpo(base, expo-1)*base)%mod;
}
else{
val = binaryExpo(base, expo/2);
val = (val*val)%mod;
}
return (val%mod);
}
public static boolean isSorted(int[]arr){
for(int i =1;i<arr.length;i++){
if(arr[i] < arr[i-1]){
return false;
}
}
return true;
}
//function to find the topological sort of the a DAG
public static boolean hasCycle(int[]indegree,List<List<Integer>>list,int n,List<Integer>topo){
Queue<Integer>q = new LinkedList<>();
for(int i =1;i<indegree.length;i++){
if(indegree[i] == 0){
q.add(i);
topo.add(i);
}
}
while(!q.isEmpty()){
int cur = q.poll();
List<Integer>l = list.get(cur);
for(int i = 0;i<l.size();i++){
indegree[l.get(i)]--;
if(indegree[l.get(i)] == 0){
q.add(l.get(i));
topo.add(l.get(i));
}
}
}
if(topo.size() == n)return false;
return true;
}
// function to find the parent of any given node with path compression in DSU
public static int find(int val,int[]parent){
if(val == parent[val])return val;
return parent[val] = find(parent[val],parent);
}
// function to connect two components
public static void union(int[]rank,int[]parent,int u,int v){
int a = find(u,parent);
int b= find(v,parent);
if(a == b)return;
if(rank[a] == rank[b]){
parent[b] = a;
rank[a]++;
}
else{
if(rank[a] > rank[b]){
parent[b] = a;
}
else{
parent[a] = b;
}
}
}
//
public static int findN(int n){
int num = 1;
while(num < n){
num *=2;
}
return num;
}
// code for input
public static void print(String s ){
System.out.print(s);
}
public static void print(int num ){
System.out.print(num);
}
public static void print(long num ){
System.out.print(num);
}
public static void println(String s){
System.out.println(s);
}
public static void println(int num){
System.out.println(num);
}
public static void println(long num){
System.out.println(num);
}
public static void println(){
System.out.println();
}
public static int Int(String s){
return Integer.parseInt(s);
}
public static long Long(String s){
return Long.parseLong(s);
}
public static String[] nextStringArray()throws IOException{
return bf.readLine().split(" ");
}
public static String nextString()throws IOException{
return bf.readLine();
}
public static long[] nextLongArray(int n)throws IOException{
String[]str = bf.readLine().split(" ");
long[]arr = new long[n];
for(int i =0;i<n;i++){
arr[i] = Long.parseLong(str[i]);
}
return arr;
}
public static int[][] newIntMatrix(int r,int c)throws IOException{
int[][]arr = new int[r][c];
for(int i =0;i<r;i++){
String[]str = bf.readLine().split(" ");
for(int j =0;j<c;j++){
arr[i][j] = Integer.parseInt(str[j]);
}
}
return arr;
}
public static long[][] newLongMatrix(int r,int c)throws IOException{
long[][]arr = new long[r][c];
for(int i =0;i<r;i++){
String[]str = bf.readLine().split(" ");
for(int j =0;j<c;j++){
arr[i][j] = Long.parseLong(str[j]);
}
}
return arr;
}
static class pair{
int one;
int two;
pair(int one,int two){
this.one = one ;
this.two =two;
}
}
public static long gcd(long a,long b){
if(b == 0)return a;
return gcd(b,a%b);
}
public static long lcm(long a,long b){
return (a*b)/(gcd(a,b));
}
public static boolean isPalindrome(String s){
int i = 0;
int j = s.length()-1;
while(i<=j){
if(s.charAt(i) != s.charAt(j)){
return false;
}
i++;
j--;
}
return true;
}
// these functions are to calculate the number of smaller elements after self
public static void sort(int[]arr,int l,int r){
if(l < r){
int mid = (l+r)/2;
sort(arr,l,mid);
sort(arr,mid+1,r);
smallerNumberAfterSelf(arr, l, mid, r);
}
}
public static void smallerNumberAfterSelf(int[]arr,int l,int mid,int r){
int n1 = mid - l +1;
int n2 = r - mid;
int []a = new int[n1];
int[]b = new int[n2];
for(int i = 0;i<n1;i++){
a[i] = arr[l+i];
}
for(int i =0;i<n2;i++){
b[i] = arr[mid+i+1];
}
int i = 0;
int j =0;
int k = l;
while(i<n1 && j < n2){
if(a[i] < b[j]){
arr[k++] = a[i++];
}
else{
arr[k++] = b[j++];
}
}
while(i<n1){
arr[k++] = a[i++];
}
while(j<n2){
arr[k++] = b[j++];
}
}
public static String next(){
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(bf.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
static int nextInt() {
return Integer.parseInt(next());
}
static long nextLong() {
return Long.parseLong(next());
}
static double nextDouble() {
return Double.parseDouble(next());
}
static String nextLine(){
String str = "";
try {
str = bf.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
// use some math tricks it might help
// sometimes just try to think in straightforward plan in A and B problems don't always complecate the questions with thinking too much differently
// always use long number to do 10^9+7 modulo
// if a problem is related to binary string it could also be related to parenthesis
// *****try to use binary search(it is a very beautiful thing it can work in some of the very unexpected problems ) in the question it might work******
// try sorting
// try to think in opposite direction of question it might work in your way
// if a problem is related to maths try to relate some of the continuous subarray with variables like - > a+b+c+d or a,b,c,d in general
// if the question is to much related to left and/or right side of any element in an array then try monotonic stack it could work.
// in range query sums try to do binary search it could work
// analyse the time complexity of program thoroughly
// anylyse the test cases properly
// if we divide any number by 2 till it gets 1 then there will be (number - 1) operation required
// try to do the opposite operation of what is given in the problem
//think about the base cases properly
//If a question is related to numbers try prime factorisation or something related to number theory
// keep in mind unique strings
//you can calculate the number of inversion in O(n log n)
// in a matrix you could sometimes think about row and cols indenpendentaly.
// Try to think in more constructive(means a way to look through various cases of a problem) way.
// observe the problem carefully the answer could be hidden in the given test cases itself. (A, B , C);
// when we have equations like (a+b = N) and we have to find the max of (a*b) then the values near to the N/2 must be chosen as (a and b);
// give emphasis to the number of occurences of elements it might help.
// if a number is even then we can find the pair for each and every number in that range whose bitwise AND is zero.
// if a you find a problem related to the graph make a graph | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | a3e362188e3c859f5eb8867f23c07a9b | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.BigInteger;
import static java.lang.Math.min;
import static java.lang.Math.max;
import static java.lang.Math.abs;
public class CodeForces {
static int mod=1000000000+7;
static FastScanner in=new FastScanner();
static PrintWriter out=new PrintWriter(System.out);
//try to use as much bit manipulation as you can
//rather than using delete option in arraylist prefer using queue
//in multiplying and dividing by 2 use left and right shift operator
//number of bits in 1101(no=13) is 4,, shortcut is {(int)(log no base 2)+1}
//number of set bits
/* while(n!=0){
*
* if(n%2!=0)
* count++;
*
* n=n>>1;
*
* } */
//if a^b=c then a^c=b and b^c=a
//suppose in addition of several bits what get written is sum%2 and whats get carried to the left is sum/2
// no^no=0 && no^0=no
/* no of subaraays with the given element with i being the zero based indexing of the element
and n being the total number elements of the array..(i+1)*(n-i) */
public static void main(String[] args) {
int T=in.nextInt();
//int T=1;
for (int tt=0; tt<T; tt++) {
//begin
int n=in.nextInt(),l=in.nextInt(),r=in.nextInt();boolean temp=false;
List<Integer> list=new ArrayList<Integer>();
for(int i=n;i>=1;i--) {
int k=r-r%i;
if(k<l) {
temp=true;break;
}else
list.add(k);
}
if(temp)
pn();
else {
py();//p(list);
for(int j=list.size()-1;j>=0;j--)
out.print (list.get(j)+" ");
out.println();
}
//end
}
out.close();
}
static class Pair implements Comparable<Pair>{
int first;int second;
Pair(int first,int second){
this.first=first;
this.second=second;
}
public int compareTo(Pair o){
return o.second-this.second;
}
}
static Pair[] pair(Map<Integer,Integer> map) {
Pair pair[]=new Pair[map.size()];int i=0;
for(int ele:map.keySet()) {
pair[i]=new Pair(ele,map.get(ele));i++;}
Arrays.sort(pair);
return pair;
}
static Map map(int[] ar) {
Map<Integer,Integer> map=new HashMap<>();
for(int i=0;i<ar.length;i++) {
if(map.containsKey(ar[i]))
map.put(ar[i], map.get(ar[i])+1);
else
map.put(ar[i], 1);
}
return map;
}
static<T> void p(T abcd) {
out.println(abcd);
}
static void py() {
out.println("YES");
}
static void pn() {
out.println("NO");
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static void sortd(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l,Comparator.reverseOrder());
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
String nextLine(){
String str = "";
try{
str = br.readLine();
}catch (IOException e){
e.printStackTrace();
}
return str;
}
int nextInt() {
return Integer.parseInt(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
String[] readStringArray(int n) {
String[] a=new String[n];
for (int i=0; i<n; i++) a[i]=next();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 3db0f6baddc832ca5d3b999e7018f2ea | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class DifferenceofGCDs {
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException ignored) {
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
}
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int t = sc.nextInt();
pls:
while (t-- > 0) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
for (int i = 1; i <= n; i++) {
if ((r - (r % i)) < l) {
System.out.println("NO");
continue pls;
}
}
System.out.println("YES");
for (int i = 1; i <= n; i++) {
System.out.print((r - (r % i)) + " ");
}
System.out.println();
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 261355011b160587030d6b1251975183 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
// commmon mistake::
// 1. Think reverse
// 2. Traverse from back
// 3. when you think that i have to see all the subarray , then think to do tat problem by answerin the contribution of every element.
// 4. In grid problems,remember one thing if its given 4 direction always go with graphs
public class Problem {
static int Mod = 1000000007;
// static int Mod=998244353;
// static int count[];
static long dp[][];
// static int ans;
public static void main(String[] args) {
MyScanner scan = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int t= scan.nextInt();
while(t-->0){
int n= scan.nextInt();
long l= scan.nextLong();
long r= scan.nextLong();
long a[]= new long [n+1];
boolean ans=true;
Set<Long> map= new HashSet<>();
for(long i=n;i>=1;i--){
long k= (l%i==0)? l/i: l/i+1;
k=k*i;
if(k>r) {
ans=false;
break;
}
a[(int)i]=k;
}
if(ans){
out.println("YES");
for(int i=1;i<=n;i++) out.print(a[(int)i]+" ");
out.println();
}else out.println("NO");
}
out.close();
}
static void swap(int a[], int i, int j){
int temp= a[i];
a[i]=a[j];
a[j]=temp;
}
static boolean isPalindrome(String s) {
StringBuilder s1 = new StringBuilder(s);
s1.reverse();
if (s.equals(s1.toString()))
return true;
return false;
}
static boolean isPrime(int n){
if(n==2) return true;
for(int i=2;i*i<=n;i++){
if(n%i==0) return false;
}
return true;
}
static class Pair {
long l;
long r;
Pair(long l, long r) {
this.l = l;
this.r = r;
}
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + l;
// result = prime * result + r;
// return result;
// }
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (l != other.l)
// return false;
// if (r != other.r)
// return false;
// return true;
// }
@Override
public String toString() {
return "Pair [l=" + l + ", r=" + r + "]";
}
}
// Longest non-decreasing sequence
static int LIS(int a[]) {
ArrayList<Integer> list = new ArrayList<>();
list.add(a[0]);
for (int i = 1; i < a.length; i++) {
int idx = Collections.binarySearch(list, a[i]);
if (idx < 0) {
idx = -idx - 1;
if (idx == list.size())
list.add(a[i]);
else
list.set(idx, a[i]);
} else {
while (idx < list.size()) {
if (list.get(idx) != a[i]) {
list.set(idx, a[i]);
break;
}
idx++;
}
if (idx == list.size())
list.add(a[i]);
}
}
return list.size();
}
static ArrayList<Integer> digits(long n) {
ArrayList<Integer> list = new ArrayList<>();
while (n > 0) {
list.add((int) (n % 10l));
n = n / 10l;
}
Collections.reverse(list);
return list;
}
public static void reverse(int a[]) {
int n = a.length;
for (int i = 0; i < n / 2; i++) {
int temp = a[i];
a[i] = a[n - i - 1];
a[n - i - 1] = temp;
}
}
public static void sort(int[] array) {
ArrayList<Integer> copy = new ArrayList<>();
for (Integer i : array)
copy.add(i);
Collections.sort(copy);
for (int i = 0; i < array.length; i++)
array[i] = copy.get(i);
}
public static void sort(long[] array) {
ArrayList<Long> copy = new ArrayList<>();
for (Long i : array)
copy.add(i);
Collections.sort(copy);
for (int i = 0; i < array.length; i++)
array[i] = copy.get(i);
}
public static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b); // gcd(a,b) = gcd(a-b,b) or gcd(a,b) = gcd(b,a%b) where a>b
}
public static int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b); // gcd(a,b) = gcd(a-b,b) or gcd(a,b) = gcd(b,a%b) where a>b
}
public static long lcm(long a, long b) {
return (a / gcd(a, b)) * b;
}
static long power(long x, long y) {
long temp;
if (y == 0) // a^b= (a^b/2)^2 if b is even
return 1; // = (a*a^(b-1)) if b is odd
temp = power(x, y / 2);
if (y % 2 == 0)
return temp * temp;
else
return x * temp * temp;
}
static long mod(long x) {
return ((x % Mod + Mod) % Mod);
}
static long add(long a, long b) {
return mod(mod(a) + mod(b));
}
static int mod(int x) {
return ((x % Mod + Mod) % Mod);
}
static int add(int a, int b) {
return mod(mod(a) + mod(b));
}
static int sub(int a, int b) {
return mod(mod(a) - mod(b) + Mod);
}
static long mul(long a, long b) {
return mod(mod(a) * mod(b));
}
static long pow(long x, long y, long p) {
long res = 1; // Initialize result
x = x % p; // Update x if it is more than or equal to p
if (x == 0)
return 0; // In case x is divisible by p;
while (y > 0) {
// If y is odd, multiply x with result
if ((y & 1) != 0)
res = (res * x) % p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return (res+p)%p;
}
static long modInverse(long a, long m) {
// int g = gcd(a, m);
// if (g != 1)
// System.out.println("Inverse doesn't exist");
// else {
// // If a and m are relatively prime, then modulo
// // inverse is a^(m-2) mode m
// return power(a, m - 2, m);
// }
return pow(a, m - 2, m);
}
}
class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 27a584020e8727b747c84a4e24cba5e1 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class A {
static class Pair {
int x;
int y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
}
static int gcd(int n, int m) {
if (m == 0)
return n;
return gcd(m, n % m);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder str = new StringBuilder();
int t = sc.nextInt();
for (int xx = 0; xx < t; xx++) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
long[] ar = new long[n];
int ok = 1;
for (int i = 1; i <= n; i++) {
long high = r / i;
long e = high * i;
long low = (l / i);
long e1 = low * i;
if(e<l||low>r)
{
ok=0;
}
else
{
ar[i-1]=e;
}
}
if (ok == 0)
str.append("NO" + "\n");
else {
str.append("YES" + "\n");
for (long i : ar)
str.append(i + " ");
str.append("\n");
}
}
System.out.println(str);
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 44abe1d6a81c1cf6d0032af58a8289f8 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
import static java.lang.Math.*;
public class Main {
static double pi = 3.141592653589;
static int mod = (int) 1e9 + 7;
public static void main(String[] args) throws IOException {
int qwe = in.nextInt();
while (qwe-- > 0)
{
solve();
}
out.close();
}
/*
*/
public static void solve() {
int n = in.nextInt();
int l = in.nextInt();
int r = in.nextInt();
int[] a = new int[n];
boolean ok = false;
int idx = 0;
for (int i = 1; i <= n; i++) {
int b = r / i * i;
if (b < l){
ok = true;
break;
}else {
a[idx++] = b;
}
}
if (ok){
out.println("NO");
}else {
out.println("YES");
for (int i = 0; i < n; i++) {
out.print(a[i]+" ");
}
out.println();
out.flush();
}
}
static class pair {
int min;
int max;
public pair(int a, int b) {
this.min = a;
this.max = b;
}
}
/*
*/
// static int N = 1010;
// static int n,m;
// static int INF = 0x3f3f3f3f;
// static int[][] g = new int[N][N]; // 存储每条边 邻接矩阵
// static int[] dist = new int[N]; // 存储1号点到每个点的最短距离
// static boolean[] st = new boolean[N]; // 存储每个点的最短路是否已经确定
// static void init(){
// Arrays.fill(dist, INF);
// for (int i = 0; i <= n; i++) Arrays.fill(g[i],0x3f3f3f3f);
// }
// // 求x号点到y号点的最短路,如果不存在则返回-1
// static int dijkstra(int x, int y) {
// dist[x] = 0;
// for (int i = 1; i < n; i++) {
// int t = -1; // 在还未确定最短路的点中,寻找距离最小的点
// for (int j = 1; j <= n; j++)
// if (!st[j] && (t == -1 || dist[t] > dist[j]))
// t = j;
//
// st[t] = true;
// // 用t更新其他点的距离
// for (int j = 1; j <= n; j++) dist[j] = Math.min(dist[j], dist[t] + g[t][j]);
// }
// if (dist[y] == INF) return -1;
// return dist[y];
// }
// static int N = 1000 * 26;
// static int[][] trie = new int[N][26];;
// static int[] cnt = new int[N];
// static int idx;
// static void insert_trie(String s) {
// int p = 0;
// for (int i = 0; i < s.length(); i++) {
// int u = s.charAt(i) - 'a'; //如果是大写字母,则需要改成大写A
// if (trie[p][u] == 0) trie[p][u] = ++idx;
// p = trie[p][u];
// }
// cnt[p]++;
// }
// static int search_trie(String s){
// int p = 0;
// for (int i = 0; i < s.length(); i ++ ){
// int u = s.charAt(i) - 'a';
// if (trie[p][u] == 0) return 0;
// p = trie[p][u];
// }
// return cnt[p];
// }
static void kmp(String s1, String s2) { //短字符串、长字符串
int n = s1.length(); //短字符串
int m = s2.length();
char[] p = (" " + s1).toCharArray();//短字符串
char[] s = (" " + s2).toCharArray();
// 构造ne数组
int[] ne = new int[n + 1];
for (int i = 2, j = 0; i <= n; i++) {
while (j != 0 && p[i] != p[j + 1]) j = ne[j];
if (p[i] == p[j + 1]) j++;
ne[i] = j;
}
// kmp匹配
for (int i = 1, j = 0; i <= m; i++) {
while (j != 0 && s[i] != p[j + 1]) j = ne[j];
if (s[i] == p[j + 1]) j++;
if (j == n) { // 匹配了n字符了即代表完全匹配了
out.print(i - n + " "); // 输出在s串中p出现的位置
j = ne[j]; // 完全匹配后继续搜索
}
out.flush();
}
}
// static int N = 100010;
// static int idx = 0; //节点位置
// static char[] str = new char[N];
// static int[] cnt = new int[N];
// static int[][] son = new int[N][26];
// public static void insert(char[] str) {
// int p = 0; //从根节点出发
// for (char i : str) {
// int u = i - 'a';
// if (son[p][u] == 0) son[p][u] = ++idx;
// p = son[p][u];
// }
// cnt[p]++;
// }
// public static int query(char[] str) {
// int p = 0;
// for (char i : str) {
// int u = i - 'a';
// if (son[p][u] == 0) return 0;
// p = son[p][u];
// }
// return cnt[p];
// }
// static int bsearch_l(int l, int r, long target) {
// while (l < r) {
// int mid = l + r >> 1;
// if (num[mid] >= target) r = mid;
// else l = mid + 1;
// }
// return l;
// }
//
// static int bsearch_r(int l, int r, long target) {
// while (l < r) {
// int mid = l + r + 1 >> 1;
// if (num[mid] <= target) l = mid;
// else r = mid - 1;
// }
// return l;
// }
// static double bsearch_d(double l, double r) {
// double eps = 1e-8;
// while (Math.abs(r - l) > eps) {
// double mid = (l + r) / 2;
// if (check(mid)) r = mid;
// else l = mid;
// }
// return l;
// }
// static boolean check(int mid) {
// return true;
// }
public static long ksm(long n, long m) {//本质为n^m
long res = 1, base = n;
while (m != 0) {
if ((m & 1) == 1) { //等价于m%2==1,也就是m为奇数时
res = mul(res, base) % mod;
}
base = mul(base, base) % mod;//m为偶数时,base自乘
m = m >> 1;//等价于m/2
}
return res % mod;
}
static long mul(long a, long b) {//本质为a*b
long ans = 0;
while (b != 0) {
if ((b & 1) == 1) {
ans = (ans + a) % mod;
}
a = (a + a) % mod;
b = b >> 1;
}
return ans % mod;
}
public static long cnm(int a, int b) {
long sum = 1;
int i = a, j = 1;
while (j <= b) {
sum = sum * i / j;
i--;
j++;
}
return sum;
}
public static long gcd(long a, long b) {
return b == 0 ? a : gcd(b, a % b);
}
public static long lcm(long a, long b) {
return (a * b) / gcd(a, b);
}
public static void gbSort(int[] a, int l, int r) {
if (l < r) {
int m = (l + r) >> 1;
gbSort(a, l, m);
gbSort(a, m + 1, r);
int[] t = new int[r - l + 1];
int idx = 0, i = l, j = m + 1;
while (i <= m && j <= r)
if (a[i] <= a[j]) t[idx++] = a[i++];
else t[idx++] = a[j++];
while (i <= m) t[idx++] = a[i++];
while (j <= r) t[idx++] = a[j++];
for (int z = 0; z < t.length; z++) a[l + z] = t[z];
}
}
static InputReader in = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
boolean hasNext() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (Exception e) {
return false;
// TODO: handle exception
}
}
return true;
}
public String nextLine() {
String str = null;
try {
str = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public Double nextDouble() {
return Double.parseDouble(next());
}
public BigInteger nextBigInteger() {
return new BigInteger(next());
}
public BigDecimal nextBigDecimal() {
return new BigDecimal(next());
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | e7b8e1436eae92f13cd14d390ba31baa | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class CF808 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
ArrayList<Integer> arr = new ArrayList<>();
boolean c = true;
arr.add(l);
int start = l;
int curr = 2;
while(curr<=n) {
start = l;
int temp = start%curr;
if(temp==0) {
if(start>r) {
c = false;
break;
}
arr.add(start);
// start++;
curr++;
}
else {
temp = curr - temp;
start+=temp;
if(start>r) {
c = false;
break;
}
arr.add(start);
// start++;
curr++;
}
}
if(c) {
System.out.println("YES");
for(int a:arr) {
System.out.print(a+" ");
}
System.out.println();
}
else {
System.out.println("NO");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 258ecae124c3b786e924ab0f47b7801e | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes |
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;
public class Main {
static Uzi uzi;
static int counter = 0;
// static int[][] dp;
static int[] dp;
// static ArrayList<Integer> list;
static int[] list;
static long MOD = (long)1e9 + 7;
static int size = 0;
static HashMap<Character, String> map;
static boolean[][] visited;
// static int[] arr, brr;
public static void main(String[] args) throws IOException {
FastReader fk = new FastReader();
PrintWriter pr = new PrintWriter(System.out);
// uzi = new Uzi();
// uzi.seive();
int t = fk.nextInt();
// int t = 1;
while (t-- > 0) {
int n = fk.nextInt(), l = fk.nextInt(), r = fk.nextInt();
if(n == 1)
System.out.println("YES" + "\n" + l);
else
fxn(n, l, r) ;
}
pr.close();
}
private static void fxn(int n, int l, int r) {
int[] arr = new int[n];
boolean flag = false;
for(int i = 1; i<=n; i++) {
arr[i-1] = (((l-1)/i) + 1) * i;
if(arr[i-1] > r) {
flag = true;
break;
}
}
if(flag)
System.out.println("NO");
else {
System.out.println("YES");
for(int i : arr)
System.out.print(i +" ");
System.out.println();
}
}
}
class Uzi {
boolean[] primes;
int N;
long[] fact;
public Uzi() {
}
public Uzi(int n) {
this.N = n;
this.primes = new boolean[N + 1];
this.fact = new long[N + 1];
}
public long fast_exponentiation(long n, long b, long mod) {
// Time complexity: O(logn), Space complexity: O(1)
long res = 1;
while (b > 0) {
res = (res * (b % 2 == 1 ? n : 1)) % mod;
n = (n * n) % mod;
b >>= 1;
}
return res;
}
public void fact() {
fact[0] = 1;
for (int i = 1; i <= N; i++) {
fact[i] = i * fact[i - 1];
}
}
public long gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
public void seive() {
Arrays.fill(primes, true);
primes[0] = primes[1] = false;
for (int i = 2; i * i <= N; i++) {
if (primes[i]) {
for (int j = i * i; j <= N; j += i)
primes[j] = false;
}
}
}
public int countDivisors(long num) {
int counter = 0;
for (int i = 1; i*i <= num ; i++) {
if (num % i == 0)
counter += (i * i == num) ? 1 : 2;
}
return counter;
}
public boolean binary_search(int[] arr, long key) {
int s = 0, e = arr.length - 1, curr;
while (s <= e) {
curr = (s + e) / 2;
if (arr[curr] == key)
return true;
else {
if (arr[curr] > key)
e = curr - 1;
else
s = curr + 1;
}
}
return false;
}
private int elementJustGreater(int[] arr, int k) {
// to find the first arr[i] >= k using binary search
int s = 0, e = arr.length - 1, curr;
int ans = -1;
while (s <= e) {
curr = (s + e) / 2;
if (arr[curr] >= k) {
ans = arr[curr];
e = curr - 1;
} else
s = curr + 1;
}
return ans;
}
public int[] elementJustSmaller(int[] arr, long k) {
// to find the first arr[i] <= k using binary search
int s = 0, e = arr.length - 1, curr;
int[] ans = {-1, 0};
while (s <= e) {
curr = (s + e) / 2;
if (arr[curr] <= k) { // should be less than or equal to
//ans = arr[curr];
if (arr[curr] == k)
ans = new int[]{curr, 0};
else
ans = new int[]{curr, 1};
s = curr + 1;
} else
e = curr - 1;
}
return ans;
}
}
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | a9b8e684932e382fcabf5d0687174915 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.awt.image.AreaAveragingScaleFilter;
import java.io.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
public class Pratice {
static final long mod = 1000000007;
static StringBuilder sb = new StringBuilder();
static int xn = (int) (2e5 + 10);
static long ans;
static boolean prime[] = new boolean[1000001];
// calculate sqrt and cuberoot
// static Set<Long> set=new TreeSet<>();
// static
// {
// long n=1000000001;
//
//
// for(int i=1;i*i<=n;i++)
// {
// long x=i*i;
// set.add(x);
// }
// for(int i=1;i*i*i<=n;i++)
// {
// long x=i*i*i;
// set.add(x);
// }
// }
static void sieveOfEratosthenes() {
for (int i = 0; i <= 1000000; i++)
prime[i] = true;
prime[0] = false;
prime[1] = false;
for (int p = 2; p * p <= 1000000; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= 1000000; i += p)
prime[i] = false;
}
}
}
public static void main(String[] args) throws IOException {
Reader reader = new Reader();
int t = reader.nextInt();
while (t-- > 0) {
int n=reader.nextInt();
int l=reader.nextInt();
int r=reader.nextInt();
int res[]=new int[n+1];
res[1]=l;
int count=1;
int ind=2;
for(int i=2;i<=n;i++)
{
if(l%i==0)
{
res[ind++]=l;
count++;
}
else {
int range=l/i;
range=(range+1)*i;
if(range<=r)
{
res[ind++]=range;
count++;
}
else {
break;
}
}
}
if(count>=n)
{
System.out.println("Yes");
for(int i=1;i<=n;i++)
{
System.out.print(res[i] + " ");
}
}
else {
System.out.println("No");
}
}
}
// }
// static void SieveOfEratosthenes(int n, boolean prime[],
// boolean primesquare[], int a[])
// {
// // Create a boolean array "prime[0..n]" and
// // initialize all entries it as true. A value
// // in prime[i] will finally be false if i is
// // Not a prime, else true.
// for (int i = 2; i <= n; i++)
// prime[i] = true;
//
// /* Create a boolean array "primesquare[0..n*n+1]"
// and initialize all entries it as false.
// A value in squareprime[i] will finally
// be true if i is square of prime,
// else false.*/
// for (int i = 0; i < ((n * n) + 1); i++)
// primesquare[i] = false;
//
// // 1 is not a prime number
// prime[1] = false;
//
// for (int p = 2; p * p <= n; p++) {
// // If prime[p] is not changed,
// // then it is a prime
// if (prime[p] == true) {
// // Update all multiples of p
// for (int i = p * 2; i <= n; i += p)
// prime[i] = false;
// }
// }
//
// int j = 0;
// for (int p = 2; p <= n; p++) {
// if (prime[p]) {
//
// a[j] = p;
//
//
// primesquare[p * p] = true;
// j++;
// }
// }
// }
//
//
// static int countDivisors(int n)
// {
//
// if (n == 1)
// return 1;
//
// boolean prime[] = new boolean[n + 1];
// boolean primesquare[] = new boolean[(n * n) + 1];
//
// int a[] = new int[n];
//
//
// SieveOfEratosthenes(n, prime, primesquare, a);
//
//
// int ans = 1;
//
// // Loop for counting factors of n
// for (int i = 0;; i++) {
// // a[i] is not less than cube root n
// if (a[i] * a[i] * a[i] > n)
// break;
//
// int cnt = 1;
//
// // if a[i] is a factor of n
// while (n % a[i] == 0) {
// n = n / a[i];
//
// // incrementing power
// cnt = cnt + 1;
// }
//
//
// ans = ans * cnt;
// }
//
//
// if (prime[n])
// ans = ans * 2;
//
// // Second case
// else if (primesquare[n])
// ans = ans * 3;
//
// // Third case
// else if (n != 1)
// ans = ans * 4;
//
// return ans; // Total divisors
// }
public static long[] inarr(long n) throws IOException {
Reader reader = new Reader();
long arr[]=new long[(int) n];
for (long i = 0; i < n; i++) {
arr[(int) i]=reader.nextLong();
}
return arr;
}
public static boolean checkPerfectSquare(int number)
{
int x=number % 10;
if (x==2 || x==3 || x==7 || x==8)
{
return false;
}
for (int i=0; i<=number/2 + 1; i++)
{
if (i*i==number)
{
return true;
}
}
return false;
}
// check number is prime or not
public static boolean isPrime(int n) {
return BigInteger.valueOf(n).isProbablePrime(1);
}
// return the gcd of two numbers
public static long gcd(long a, long b)
{
BigInteger b1 = BigInteger.valueOf(a);
BigInteger b2 = BigInteger.valueOf(b);
BigInteger gcd = b1.gcd(b2);
return gcd.longValue();
}
// return lcm of number
static long lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
// number of digits in the given number
public static long numberOfDigits(long n)
{
long ans= (long) (Math.floor((Math.log10(n)))+1);
return ans;
}
// return most significant bit in the number
public static long mostSignificantNumber(long n)
{
double k=Math.log10(n);
k=k-Math.floor(k);
int ans=(int)Math.pow(10,k);
return ans;
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException {
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException {
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n')
break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
if (din == null)
return;
din.close();
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | fb436ffcf0cff1be6d46e486a8e1e0bc | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class GCDdifference {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int T = Integer.parseInt(st.nextToken());
for(int count=0;count<T;count++)
{
st = new StringTokenizer(br.readLine());
int N=Integer.parseInt(st.nextToken());
int L=Integer.parseInt(st.nextToken());
int R=Integer.parseInt(st.nextToken());
int ret[]=new int[N];
boolean works=true;
for(int i=N;i>0;i--)
{
int start=L/i*i;
while(true)
{
if(start>=L&&start<=R)
{
ret[i-1]=start;
break;
}
if(start>R)
{
works=false;
break;
}
start+=i;
}
if(!works)
{
break;
}
}
if(works)
{
System.out.println("Yes");
for(int a:ret)
{
System.out.print(a+" ");
}
}
else
{
System.out.println("No");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | b295805143efc1a83073be6481a0b40f | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class cf1708B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
int arr[] = new int[n];
int f = 0;
for(int i = 0;i<n;i++){
int x = ((int)Math.floor((l-1)/(i+1)) + 1)*(i+1);
if(x<=r) arr[i] = x;
else{
f = 1;
break;
}
}
if(f == 1){
System.out.println("NO");
}
else{
System.out.println("YES");
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | a87b37f2c47ca2b5bedf0fe0164411a9 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class Codeforces {
public static void main(String[] args) {
try {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
ArrayList<Integer>ans=new ArrayList<>();
ans.add(l);
int c=1;
for(int i=2;i<=n;i++){
if(l%i==0){
ans.add(l);
c++;
}else{
int mul=l/i;
int val=(mul*i)+i;
if(val>=l && val<=r){
ans.add(val);
c++;
}else{
break;
}
}
}
if(ans.size() == n) {
System.out.println("YES");
for(Integer i:ans)
System.out.print(i+" ");
System.out.println();
}
else System.out.println("NO");
}
} catch (Exception e) {
System.out.println(e);
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 77741704c2a8db1886d2a9d259296fe6 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class main {
public static void main(String[] strgs) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-- >0) {
int n=sc.nextInt();
long l=sc.nextLong();
long r=sc.nextLong();
ArrayList<Long> ans=new ArrayList<>();
ans.add(l);
for(int i=2;i<=n;i++) {
if(l%i==0) {
ans.add(l);
}
else {
long j=l/i;
long val=(j+1)*i;
if(val<=r) {
ans.add(val);
}
else {
break;
}
}
}
if(ans.size()==n) {
System.out.println("YES");
for(int i=0;i<ans.size();i++) {
System.out.print(ans.get(i)+" ");
}
System.out.println();
}
else {
System.out.println("NO");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 92b95e61e2e26c435240432918b5828a | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static StringBuilder sb;
static dsu dsu;
static long fact[];
static int mod = (int) (1e9 + 7);
static void print(int[]arr){
for(int i=0;i<arr.length;i++){
System.out.print(arr[i]+" ");
}
System.out.println();
}
static void print(int t){
System.out.println(t);
}
static long get1(long val,long p){
for(long i=0;i<p;i++){
val=(long)val/2;
}
return val;
}
static int get(long t, ArrayList<Long>temp, long[][]arr,long n){
if(t<n)return (int)t;
for(int i=1;i<temp.size();i++){
long l=temp.get(i-1);
long r=temp.get(i)-1;
if(t>=l&&t<=r){
long dis=t-l;
return get(arr[i-1][0]+dis,temp,arr,n);
}
}
return -1;
}
static void solve() {
int n=i();
long l=l();
long r=l();
int[]ans=new int[n+1];
Arrays.fill(ans,-1);
ans[1]=(int)l;
for(int i=1;i<=n;i++){
long t=l%i;
long num=i-t;
if(t==0)num=0;
num+=l;
if(num<=r)ans[i]=(int)num;
}
for(int i=1;i<=n;i++){
if(ans[i]==-1){
sb.append("NO\n");
return;
}
}
sb.append("YES\n");
for(int i=1;i<=n;i++){
sb.append(ans[i]+" ");
}
sb.append("\n");
}
public static void main(String[] args) {
sb = new StringBuilder();
int test =i();
fact=new long[(int)1e6+10];
fact[0]=fact[1]=1;
for(int i=2;i<fact.length;i++)
{ fact[i]=((long)(i%mod)*(long)(fact[i-1]%mod))%mod; }
while (test-- > 0) {
solve();
}
System.out.println(sb);
}
//**************NCR%P******{************
static long ncr(int n, int r) {
if (r > n)
return (long) 0;
long res = fact[n] % mod;
// System.out.println(res);
res = ((long) (res % mod) * (long) (p(fact[r], mod - 2) % mod)) % mod;
res = ((long) (res % mod) * (long) (p(fact[n - r], mod - 2) % mod)) % mod;
// System.out.println(res);
return res;
}
static long p(long x, long y)// POWER FXN //
{
if (y == 0)
return 1;
long res = 1;
while (y > 0) {
if (y % 2 == 1) {
res = (res * x) % mod;
y--;
}
x = (x * x) % mod;
y = y / 2;
}
return res;
}
//**************END******************
// *************Disjoint set
// union*********//
static class dsu {
int parent[];
dsu(int n) {
parent = new int[n];
for (int i = 0; i < n; i++)
parent[i] = i;
}
int find(int a) {
if (parent[a] ==a)
return a;
else {
int x = find(parent[a]);
parent[a] = x;
return x;
}
}
void merge(int a, int b) {
a = find(a);
b = find(b);
if (a == b)
return;
parent[b] = a;
}
}
//**************PRIME FACTORIZE **********************************//
static TreeMap<Integer, Integer> prime(long n) {
TreeMap<Integer, Integer> h = new TreeMap<>();
long num = n;
for (int i = 2; i <= Math.sqrt(num); i++) {
if (n % i == 0) {
int nt = 0;
while (n % i == 0) {
n = n / i;
nt++;
}
h.put(i, nt);
}
}
if (n != 1)
h.put((int) n, 1);
return h;
}
//****CLASS PAIR ************************************************
static class Pair implements Comparable<Pair> {
int i;
int l;
Pair(int i, int l) {
this.i = i;
this.l = l;
}
public int compareTo(Pair o) {
return (int) (this.l - o.l);
}
}
//****CLASS PAIR **************************************************
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public int Int() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public String String() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public String next() {
return String();
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
static class OutputWriter {
private final PrintWriter writer;
public OutputWriter(OutputStream outputStream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}
public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}
public void print(Object... objects) {
for (int i = 0; i < objects.length; i++) {
if (i != 0)
writer.print(' ');
writer.print(objects[i]);
}
}
public void printLine(Object... objects) {
print(objects);
writer.println();
}
public void close() {
writer.close();
}
public void flush() {
writer.flush();
}
}
static InputReader in = new InputReader(System.in);
static OutputWriter out = new OutputWriter(System.out);
public static long[] sort(long[] a2) {
int n = a2.length;
ArrayList<Long> l = new ArrayList<>();
for (long i : a2)
l.add(i);
Collections.sort(l);
for (int i = 0; i < l.size(); i++)
a2[i] = l.get(i);
return a2;
}
public static char[] sort(char[] a2) {
int n = a2.length;
ArrayList<Character> l = new ArrayList<>();
for (char i : a2)
l.add(i);
Collections.sort(l);
for (int i = 0; i < l.size(); i++)
a2[i] = l.get(i);
return a2;
}
public static long pow(long x, long y) {
long res = 1;
while (y > 0) {
if (y % 2 != 0) {
res = (res * x);// % modulus;
y--;
}
x = (x * x);// % modulus;
y = y / 2;
}
return res;
}
//GCD___+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public static long gcd(long x, long y) {
if (x == 0)
return y;
else
return gcd(y % x, x);
}
// ******LOWEST COMMON MULTIPLE
// *********************************************
public static long lcm(long x, long y) {
return (x * (y / gcd(x, y)));
}
//INPUT PATTERN********************************************************
public static int i() {
return in.Int();
}
public static long l() {
String s = in.String();
return Long.parseLong(s);
}
public static String s() {
return in.String();
}
public static int[] readArrayi(int n) {
int A[] = new int[n];
for (int i = 0; i < n; i++) {
A[i] = i();
}
return A;
}
public static long[] readArray(long n) {
long A[] = new long[(int) n];
for (int i = 0; i < n; i++) {
A[i] = l();
}
return A;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 0719e8106b8b1bf23cf25e63d5b8f584 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import com.sun.jdi.IntegerValue;
import com.sun.jdi.connect.Connector;
import javax.lang.model.type.IntersectionType;
import javax.swing.*;
import java.sql.Array;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
static FastReader sc = new FastReader();
static int mod = 1000000007;
public static void main (String[] args) throws java.lang.Exception
{
int t = sc.nextInt();
while(t-->0){
solve();
}
}
public static void solve() {
int n = i();
int l = i();
int r = i();
int [] arr = new int[n+1];
for(int i = 1;i<=n;++i){
int temp = l / i;
if(l%i!=0)temp++;
if(temp * i<=r){
arr[i] = i*temp;
}else{
out.println("NO");out.flush();return;
}
}
out.println("YES");
for(int i = 1;i<=n;++i){
out.print(arr[i] + " ");
}
out.println();
out.flush();
}
/*
int [] arr = new int[n];
for(int i = 0;i<n;++i){
arr[i] = sc.nextInt();
}
*/
static int csb(long n)
{
int count = 0;
while (n > 0) {
n &= (n - 1);
count++;
}
return count;
}
static void mysort(int[] arr) {
for(int i=0;i<arr.length;i++) {
int rand = (int) (Math.random() * arr.length);
int loc = arr[rand];
arr[rand] = arr[i];
arr[i] = loc;
}
Arrays.sort(arr);
}
static long power(long x, long y)
{
long res = 1;
x = x % mod;
if (x == 0)
return 0;
while (y > 0)
{
if ((y & 1) != 0)
res = (res * x) % mod;
y = y >> 1;
x = (x * x) % mod;
}
return res;
}
static class Pair implements Comparable<Pair>{
int val;
ArrayList<Integer> list = new ArrayList<>();
Pair(int val, ArrayList<Integer> list){
this.val=val;
this.list = list;
}
public int compareTo(Pair o) {
return this.list.size() - o.list.size();
}
}
static int i() {
return sc.nextInt();
}
static String s() {
return sc.next();
}
static long l() {
return sc.nextLong();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 2262a9452a7ca0d134dcc451cbca0d6b | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main{
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader(){
br = new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static boolean isPossible(int[] arr, int n, int x) {
Arrays.sort(arr);
if(arr[n]-arr[0]<x) return false;
for(int i=0;i<n;i++) {
if(arr[i+n]-arr[i]<x) return false;
}
return true;
}
public static long sweeper(int n, int[] arr) {
long ans=0;
int i=0;
int temp = 0;
int numZero = 0;
boolean count = false;
while(i<n-1) {
if(arr[i]==0) {
if(count) {
numZero++;
i++;
}
else {
i++;
}
}
else {
if(count) {
ans+=temp+numZero;
temp=arr[i];
numZero=0;
i++;
}
else {
temp=arr[i];
numZero=0;
count=true;
i++;
}
}
}
ans+=temp+numZero;
return ans;
}
public static int lastOccur(int[] arr, int n, int key){
int l=0;
int h=n-1;
int mid;
while(l<=h){
mid = l + (h-l)/2;
if(arr[mid]==key){
if(mid==n-1) return mid;
else if(arr[mid+1]!=key) return mid;
else{
l=mid+1;
continue;
}
}
else{
if(arr[mid]>key){
h=mid-1;
continue;
}
else{
l=mid+1;
continue;
}
}
}
return -1;
}
public static int bestPos(int[] arr, int n, int key){
int l=0;
int h=n-1;
int mid;
while(l<=h){
mid=l+(h-l)/2;
if(mid==0){
if(arr[mid]>=key) return mid;
else{
l=mid+1;
continue;
}
}
else{
if(arr[mid]==key) return mid;
else if(arr[mid-1]<key && arr[mid]>key) return mid;
else if(arr[mid]>key){
h=mid-1;
continue;
}
else{
l=mid+1;
continue;
}
}
}
return l;
}
public static char[] findChar(int n, String str,int c, int[][] arr, int q, int[] queries) {
int[] left = new int[c+1];
int[] right = new int[c+1];
int[] diff = new int[c+1];
left[0]=0;
right[0]=n;
for(int i=0;i<c;i++) {
left[i+1]=right[i];
right[i+1]=left[i+1]+(arr[i][1]-arr[i][0]+1);
diff[i+1]=left[i+1]-(arr[i][0]-1);
}
// for(int i=0;i<=c;i++) {
// System.out.print(left[i]+" ");
// }
// System.out.println();
// for(int i=0;i<=c;i++) {
// System.out.print(right[i]+" ");
// }
// System.out.println();
// for(int i=0;i<=c;i++) {
// System.out.print(diff[i]+" ");
// }
// System.out.println();
char[] ans=new char[q];
for(int i=0;i<q;i++) {
int k = queries[i]-1;
int j = c;
while(k>=n) {
if(k<left[j]) {
j--;
continue;
}
else {
k-=diff[j];
j--;
}
}
ans[i]=str.charAt(k);
}
return ans;
}
public static boolean diff(int n, int[] arr) {
while(true) {
boolean minus = false;
for(int i=n-1;i>0;i--) {
if(arr[i]==0) continue;
if(arr[i-1]==0) return false;
arr[i]-=arr[i-1];
if(arr[i]<0) return false;
minus=true;
}
if(!minus) break;
}
return true;
}
public static void diffGcd(int n, int l, int r) {
int[] mul = new int[n];
for(int i=0;i<n;i++) {
mul[i]=(int)l/(i+1);
}
int[] ans = new int[n];
for(int i=0;i<n;i++) {
int j = mul[i];
int temp = j*(i+1);
while(temp<l) {
j++;
temp=j*(i+1);
}
if(temp>r) {
System.out.println("No");
return;
}
// if(hs.contains(temp)) {
// while(hs.contains(temp)) {
// j++;
// temp=j*(i+1);
// if(temp>r) {
// System.out.println("No");
// return;
// }
// }
// ans[i]=temp;
// hs.add(temp);
//
ans[i]=temp;
}
System.out.println("Yes");
for(int a:ans) {
System.out.print(a+" ");
}
System.out.println();
return;
}
public static void main(String[] args){
FastReader s = new FastReader();
int t=s.nextInt();
for(int i=0;i<t;i++){
int n=s.nextInt();
int l=s.nextInt();
int r=s.nextInt();
// int[] arr=new int[n];
// for(int j=0;j<n;j++) arr[j]=s.nextInt();
// System.out.println(diff(n, arr)?"Yes":"No");
diffGcd(n,l,r);
}
}
}
class Pair{
int val;
int index;
public Pair(int a, int b){
index=b;
val=a;
}
}
class sortPair implements Comparator<Pair>{
public int compare(Pair a,Pair b) {
return a.val-b.val;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 45414106e528c214dc64890e290e1288 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | // Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.util.*;
public class HelloWorld {
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int t = scan.nextInt();
while(t-->0){
solve();
}
}
public static void solve(){
int n = scan.nextInt();
int l = scan.nextInt();
int r = scan.nextInt();
long[] arr = new long[n+1];
for(int i =n;i>=1;i--){
if(r/i * i >=l){
arr[i] = r/i * i;
}
else{
System.out.println("NO");
return;
}
}
System.out.println("YES");
for(int x = 1;x<=n;x++){
System.out.print(arr[x] + " ");
}
System.out.println();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | a9abad9afa918f2de57a4a9d91f015b2 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.*; // iske baare me padhna hai
// sorting on the basis of count of set bits
//Arrays.sort(arr, (a,b)-> Integer.compare(Integer.bitCount(b), Integer.bitCount(a)));
// Arrays.sort(arr, (a, b) -> Integer.compare(a[0],b[0])); //increasing order
// Arrays.sort(arr, (a, b) -> Integer.compare(b[0],a[0])); //decreasing order
// provide key to pq, it will store the key according to the frequency (asc/desc)
// PriorityQueue <Integer> pq = new PriorityQueue <>((n1, n2) -> mp.get(n1)-mp.get(n2));
// Collections.sort(Arrays.asList(arr));
//char c[] = fs.next().toCharArray();
//int [] tmp = Arrays.copyOf(arr, n); , it copies a new array and change in one arr won't reflect in other i.e deep copy is done
// long ans = (long)a*(long)b; if a and b is of int type, otherwise overflow will occur
// very careful with type conversion in java.
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
public class Main {
// dont put 'long type' as index of the array,list or any Collections, only 'int' will work.
// System.out.println();
static long mod = 1000000007;
static double pi = 3.14159265358979323846;
static FastScanner fs = new FastScanner();
public static void main(String[] args) {
int tc = fs.nextInt();
for(int i = 0; i < tc; i++) {
solve();
}
}
static void solve() {
int n = fs.nextInt();
int l = fs.nextInt();
int r = fs.nextInt();
int [] arr = new int[n];
HashSet <Integer> st = new HashSet<>();
for(int i = 0; i < n; i++) {
int rem = l % (i+1);
int x = l;
if(rem != 0) {
x += (i+1-rem);
}
//System.out.println(x);
for(int j = x; j <= r; j+=x) {
int hcf = gcd(i+1, j);
if(!st.contains(hcf)) {
st.add(hcf);
arr[i] = j;
break;
}
}
}
if(st.size() == n) {
System.out.println("YES");
for(int i = 0; i < n; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
}
else {
System.out.println("NO");
}
}
static int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b%a, a);
}
}
class Pair {
int fr;
int sc;
public Pair(int fr, int sc) {
this.fr = fr;
this.sc = sc;
}
}
class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
// read only string and breaks if finds a space
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
// read a complete line of string including spaces
String nextLine() {
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 22d43a55845f903a192d747fe9291898 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.*; // iske baare me padhna hai
// sorting on the basis of count of set bits
//Arrays.sort(arr, (a,b)-> Integer.compare(Integer.bitCount(b), Integer.bitCount(a)));
// Arrays.sort(arr, (a, b) -> Integer.compare(a[0],b[0])); //increasing order
// Arrays.sort(arr, (a, b) -> Integer.compare(b[0],a[0])); //decreasing order
// provide key to pq, it will store the key according to the frequency (asc/desc)
// PriorityQueue <Integer> pq = new PriorityQueue <>((n1, n2) -> mp.get(n1)-mp.get(n2));
// Collections.sort(Arrays.asList(arr));
//char c[] = fs.next().toCharArray();
//int [] tmp = Arrays.copyOf(arr, n); , it copies a new array and change in one arr won't reflect in other i.e deep copy is done
// long ans = (long)a*(long)b; if a and b is of int type, otherwise overflow will occur
// very careful with type conversion in java.
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
public class Main {
// dont put 'long type' as index of the array,list or any Collections, only 'int' will work.
// System.out.println();
static long mod = 1000000007;
static double pi = 3.14159265358979323846;
static FastScanner fs = new FastScanner();
public static void main(String[] args) {
int tc = fs.nextInt();
for(int i = 0; i < tc; i++) {
solve();
}
}
static void solve() {
int n = fs.nextInt();
int l = fs.nextInt();
int r = fs.nextInt();
int [] arr = new int[n];
HashSet <Integer> st = new HashSet<>();
for(int i = 0; i < n; i++) {
int rem = l % (i+1);
int x = l;
if(rem != 0) {
x += (i+1-rem);
}
//System.out.println(x);
for(int j = x; j <= r; j+=x) {
int hcf = gcd(i+1, j);
if(!st.contains(hcf)) {
st.add(hcf);
arr[i] = j;
break;
}
}
}
if(st.size() == n) {
System.out.println("YES");
for(int i = 0; i < n; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
}
else {
System.out.println("NO");
}
}
static int gcd(int a, int b)
{
int result = Math.min(a, b); // Find Minimum of a nd b
while (result > 0) {
if (a % result == 0 && b % result == 0) {
break;
}
result--;
}
return result; // return gcd of a nd b
}
}
class Pair {
int fr;
int sc;
public Pair(int fr, int sc) {
this.fr = fr;
this.sc = sc;
}
}
class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
// read only string and breaks if finds a space
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
// read a complete line of string including spaces
String nextLine() {
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | cff1a28cf1b20d4604c4c0b92e589e4f | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.PrintWriter;
public class C2 {
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
while (t > 0)
{
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int l = Integer.parseInt(st.nextToken());
int r = Integer.parseInt(st.nextToken());
int[] ans = new int[n];
boolean valid = true;
for (int i = n; i > 0; i--)
{
int nxt = l + (i - (l % i));
if (l % i == 0)
nxt = l;
boolean found = false;
while (nxt <= r)
{
//System.err.println(i + " " + nxt);
//System.err.println(set.contains(nxt));
if (gcd(nxt, i) == i) {
ans[i - 1] = nxt;
found = true;
break;
}
nxt += n;
}
if (!found)
{
pw.println("NO");
valid = false;
break;
}
}
if (valid) {
pw.println("YES");
for (int i =0 ; i < n-1; i++)
{
pw.print(ans[i] + " ");
}
pw.println(ans[n-1]);
}
--t;
}
pw.close();
}
public static long gcd(long a, long b)
{
if (a > b)
{
long temp = b;
b = a;
a = temp;
}
if (a == 0)
return b;
else return gcd(b % a, a);
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | c68a156ab2f50fbcf38afe86e905859d | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class B {
static BufferedReader br;
static StringTokenizer st;
static PrintWriter pw;
static String nextToken() {
try {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
static int nextInt() {
return Integer.parseInt(nextToken());
}
static long nextLong() {
return Long.parseLong(nextToken());
}
static double nextDouble() {
return Double.parseDouble(nextToken());
}
static String nextLine() {
try {
return br.readLine();
} catch (IOException e) {
throw new IllegalArgumentException();
}
}
static char nextChar() {
try {
return (char) br.read();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(System.out);
int t = 1;
t = nextInt();
while (t-- > 0) {
solve();
}
pw.close();
}
private static void solve() {
int n = nextInt();
int l = nextInt();
int r = nextInt();
int[] arr = new int[n + 1];
for (int i = 1; i <= n; i++) {
arr[i] = ((l - 1) / i + 1) * i;
if (arr[i] > r) {
pw.println("NO");
return;
}
}
pw.println("YES");
for (int i = 1; i <= n; i++) {
pw.print(arr[i] + " ");
}
pw.println();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 7b04c518d518cb8323691ec7cc0aa233 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class B {
static BufferedReader br;
static StringTokenizer st;
static PrintWriter pw;
static String nextToken() {
try {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
static int nextInt() {
return Integer.parseInt(nextToken());
}
static long nextLong() {
return Long.parseLong(nextToken());
}
static double nextDouble() {
return Double.parseDouble(nextToken());
}
static String nextLine() {
try {
return br.readLine();
} catch (IOException e) {
throw new IllegalArgumentException();
}
}
static char nextChar() {
try {
return (char) br.read();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(System.out);
int t = 1;
t = nextInt();
while (t-- > 0) {
solve();
}
pw.close();
}
private static void solve() {
int n = nextInt();
int l = nextInt();
int r = nextInt();
int[] arr = new int[n + 1];
for (int i = 1; i <= n; i++) {
arr[i] = l / i * i;
if (arr[i] < l) arr[i] += i;
if (arr[i] > r) {
pw.println("NO");
return;
}
}
pw.println("YES");
for (int i = 1; i <= n; i++) {
pw.print(arr[i] + " ");
}
pw.println();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 9cf6905ec364030d3279e5f2a697226d | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class B {
static BufferedReader br;
static StringTokenizer st;
static PrintWriter pw;
static String nextToken() {
try {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
static int nextInt() {
return Integer.parseInt(nextToken());
}
static long nextLong() {
return Long.parseLong(nextToken());
}
static double nextDouble() {
return Double.parseDouble(nextToken());
}
static String nextLine() {
try {
return br.readLine();
} catch (IOException e) {
throw new IllegalArgumentException();
}
}
static char nextChar() {
try {
return (char) br.read();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(System.out);
int t = 1;
t = nextInt();
while (t-- > 0) {
solve();
}
pw.close();
}
private static void solve() {
int n = nextInt();
int l = nextInt();
int r = nextInt();
int[] arr = new int[n + 1];
for (int i = 1; i <= n; i++) {
arr[i] = l / i * i;
if (arr[i] < l) arr[i] += i;
if (arr[i] > r || arr[i] < l) {
pw.println("NO");
return;
}
}
pw.println("YES");
for (int i = 1; i <= n; i++) {
pw.print(arr[i] + " ");
}
pw.println();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | bd6568c1c2bbb83ad1ea0f105f7b7363 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
public class Solution121 {
private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private final PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args) {
Solution121 solution = new Solution121();
solution.solve();
solution.close();
}
private void solve() {
int t = readInt();
for (int i = 0; i < t; i++) {
solveCase();
}
}
int gcd(int a, int b) {
if (a % b == 0)
return b;
return gcd(b, a % b);
}
private void solveCase() {
int[] a = readIntArr();
int n = a[0];
int l = a[1];
int r = a[2];
int ret[] = new int[n];
for (int i = 1; i <= n; i++) {
int vl = i * ((l - 1) / i + 1);
if (vl > r) {
pw.println("no");
return;
}
ret[i - 1] = vl;
}
pw.println("yes");
pw.print(ret[0]);
for (int i = 1; i < n; i++) {
pw.print(" " + ret[i]);
}
pw.println();
}
private void close() {
pw.close();
}
private String readLine() {
String line = null;
try {
line = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return line;
}
private String readString() {
return readLine();
}
private long readLong() {
return Long.parseLong(readLine());
}
private int readInt() {
return Integer.parseInt(readLine());
}
private String[] stringArray() {
StringTokenizer st = new StringTokenizer(readLine());
int n = st.countTokens();
String ret[] = new String[n];
for (int i = 0; i < n; i++) {
ret[i] = st.nextToken();
}
return ret;
}
private int[] readIntArr() {
String[] str = stringArray();
int arr[] = new int[str.length];
for (int i = 0; i < arr.length; i++)
arr[i] = Integer.parseInt(str[i]);
return arr;
}
private double[] readDoubleArr() {
String[] str = stringArray();
double arr[] = new double[str.length];
for (int i = 0; i < arr.length; i++)
arr[i] = Double.parseDouble(str[i]);
return arr;
}
private long[] readLongArr() {
String[] str = stringArray();
long arr[] = new long[str.length];
for (int i = 0; i < arr.length; i++)
arr[i] = Long.parseLong(str[i]);
return arr;
}
private double readDouble() {
return Double.parseDouble(readLine());
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 548a1ca9ac7e81d271667904b7891a68 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
public class Main {
public static FileReader r;
public static InputStreamReader sr;
public static BufferedReader reader;
public static BufferedWriter output;
public static void main(String[] args) throws IOException {
try {
r = new FileReader(new File("input.txt"));
reader = new BufferedReader(r);
} catch(Exception e) {
sr = new InputStreamReader(System.in);
reader = new BufferedReader(sr);
}
output = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
// -------------------------------------------------------------------
int test = Integer.parseInt(reader.readLine());
for (int tCase = 1; tCase <= test; tCase++){
int[] nlr = readIntegers();
long n = nlr[0];
long l = nlr[1];
long r = nlr[2];
ArrayList<Long> list = new ArrayList<>();
for (int i = 1; i <= n; i++) {
long x = ((l + i - 1) / i) * i;
if (x >= l && x <= r) {
list.add(x);
}
}
if (list.size() != n) {
sb.append("NO\n");
continue;
}
sb.append("YES\n");
for (long x : list) sb.append(x + " ");
sb.append("\n");
}
output.write(new String(sb));
output.flush();
}
// --------------------------------------------------------------------------
private static long nCm(long n, long r) {
long ans = 1;
for (long i = Math.max(r, n-r) + 1; i <= n; i++) ans *= i;
for (long i = Math.min(n - r, r); i > 1; i--) ans /= i;
return ans;
}
// --------------------------------------------------------------------------
private static String reverse(String s) {
StringBuffer sb = new StringBuffer(s);
StringBuffer rv = sb.reverse();
String str = new String(rv);
return str;
}
private static int[] readIntegers() throws IOException {
String[] s = reader.readLine().split(" ");
int[] arr = new int[s.length];
for (int i = 0; i < s.length; i++) arr[i] = Integer.parseInt(s[i]);
return arr;
}
private static int readInteger() throws NumberFormatException, IOException {
int n = Integer.parseInt(reader.readLine());
return n;
}
private static long readLong() throws NumberFormatException, IOException {
long x = Long.parseLong(reader.readLine());
return x;
}
private static long[] readLongs() throws NumberFormatException, IOException {
String[] s = reader.readLine().split(" ");
long[] arr = new long[s.length];
for (int i = 0; i < s.length; i++) {
arr[i] = Long.parseLong(s[i]);
}
return arr;
}
private static void reverse(int a[]) {
int i = 0, j = a.length - 1;
int temp;
while (i < j) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
i++;
j--;
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | bcdb44b8121827ed19c1f3dc7484cb85 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class Problem_B {
static FastReader scan;
public static void main(String[] args) throws Exception{
scan = new FastReader();
int tests = scan.nextInt();
boolean db = false;
if(tests == 0){
db = true;
tests = 100;
}
BufferedWriter print = new BufferedWriter(new OutputStreamWriter(System.out));
for(int testNum = 0; testNum < tests; testNum++){
solve(testNum, scan, print, db);
print.flush();
System.out.flush();
}
print.close();
}
public static void solve(int testNum, FastReader scan, BufferedWriter print, boolean db) throws Exception{
int n = scan.nextInt();
int l = scan.nextInt();
int r = scan.nextInt();
if(n > r){
print.write("NO\n");
return;
}
//System.out.println("go");
List<Integer> arr = new ArrayList<>();
for (int i = 0; i < n; i++) {
if(i == 8){
int debug = 0;
}
int index = i + 1;
long lowQuotient = l / index;
long hiQuotient = lowQuotient + 1;
long lowBound = lowQuotient * index;
long hiBound = hiQuotient * index;
if(l > lowBound && r < hiBound){
print.write("NO\n");
return;
}
long quotient = lowQuotient;
while(quotient * index < l) quotient++;
arr.add((int)(quotient * index));
}
//if(db) System.out.println("debug?");
print.write("YES\n");
writeList(print, arr);
print.write("\n");
}
//Euclid's algorithm for GCD
public static long GCD(long a, long b){
if(a == 0) return b;
if(b == 0) return a;
if(a < b) return GCD(b, a);
return GCD(b, a % b);
}
//PREWRITTEN FUNCTIONS
public static void writeList(BufferedWriter print, int[] arr) throws Exception{
for (int i = 0; i < arr.length; i++) {
if(i < arr.length-1) print.write(arr[i] + " ");
else print.write(arr[i] + "");
}
}
public static void writeList(BufferedWriter print, List<Integer> arr) throws Exception{
for (int i = 0; i < arr.size(); i++) {
if(i < arr.size()-1) print.write(arr.get(i) + " ");
else print.write(arr.get(i) + "");
}
}
public static List<Integer> readList(int n, FastReader scan){
List<Integer> res = new ArrayList<Integer>();
for(int i = 0; i < n; i++){
int next = scan.nextInt();
res.add(next);
}
return res;
}
public List<List<Integer>> read2DListSpace(int r, int c, FastReader scan){
List<List<Integer>> list2d = new ArrayList<>();
for(int i = 0; i < r; i++){
List<Integer> curRow = new ArrayList<>();
for(int j = 0; j < c; j++){
int next = scan.nextInt();
curRow.add(next);
}
list2d.add(curRow);
}
return list2d;
}
//FastReader from https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
//i really should switch to c++ but i keep finding things like this to convince myself Java is fast enough lol
static class FastReader {
BufferedReader br;
StringTokenizer st;
static boolean customInput = false;
static List<String> queue;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
queue = new LinkedList<>();
customInput = false;
}
public static void setInputMode(boolean custom){
customInput = custom;
}
public static void addToQueue(String item){
queue.add(item);
}
String next()
{
if(customInput){
String str = queue.get(0);
queue.remove(0);
return str;
}
else{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
if(st.hasMoreTokens()){
str = st.nextToken("\n");
}
else{
str = br.readLine();
}
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 38d2403205c18e7292b9b4a00737502e | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | // import static java.lang.System.out;
import static java.lang.Math.*;
import java.util.*;
import javax.naming.ContextNotEmptyException;
import javax.swing.ImageIcon;
import javax.swing.table.TableStringConverter;
import java.io.*;
import java.math.*;
import java.rmi.ConnectIOException;
public class Main {
static FastReader sc;
static long mod = ((long) 1e9) + 7;
static Tree tree;
static PrintWriter out, err;
static int imax = Integer.MAX_VALUE;
static int imin = Integer.MIN_VALUE;
static boolean testcaseBool = false;
static long lmax = Long.MAX_VALUE;
static long lmin = Long.MIN_VALUE;
static double dmax = Double.MAX_VALUE;
static double dmin = Double.MIN_VALUE;
static int max = 0;
private static void solve() throws IOException{
int n=sc.nextInt();
long l=sc.nextLong();
long r=sc.nextLong();
long[] arr=new long[n];
long prev=l;
boolean done=true;
for(int i=0;i<n;i++)
{
if(prev>r)done=false;
arr[i]=prev;
if((l%(i+2))!=0){
long v=l/(i+2);
prev=(v+1)*(i+2);
}else{
prev=l;
}
}
if(done){
print("yes");
for(int i=0;i<n;i++){
out.print(arr[i]+" ");
}
out.println();;
}else{
print("No");
}
}
public static void main(String hi[]) throws IOException {
initializeIO();
out = new PrintWriter(System.out);
err = new PrintWriter(System.err);
sc = new FastReader();
long startTimeProg = System.currentTimeMillis();
long endTimeProg;
int testCase = 1;
// Collections.sort(li);
// debug(li+"");
// debug(li+"");
testCase = sc.nextInt();
while (testCase-- != 0) {
solve();
}
endTimeProg = System.currentTimeMillis();
debug("[finished : " + (endTimeProg - startTimeProg) + ".ms ]");
out.flush();
err.flush();
// System.out.println(String.format("%.9f", max));
}
private static class Pair {
int first = 0;
int sec = 0;
int[] arr;
char ch;
String s;
Map<Integer, Integer> map;
Pair(int first, int sec) {
this.first = first;
this.sec = sec;
}
Pair(int[] arr) {
this.map = new HashMap<>();
for (int x : arr)
this.map.put(x, map.getOrDefault(x, 0) + 1);
this.arr = arr;
}
Pair(char ch, int first) {
this.ch = ch;
this.first = first;
}
Pair(String s, int first) {
this.s = s;
this.first = first;
}
}
private static Set<Long> factors(long n) {
Set<Long> res = new HashSet<>();
// res.add(n);
for (long i = 1; i * i <= (n); i++) {
if (n % i == 0) {
res.add(i);
if (n / i != i) {
res.add(n / i);
}
}
}
return res;
}
// geometrics
private static double areaOftriangle(double x1, double y1, double x2, double y2, double x3, double y3) {
double[] mid_point = midOfaLine(x1, y1, x2, y2);
// debug(Arrays.toString(mid_point)+" "+x1+" "+y1+" "+x2+" "+y2+" "+x3+" "+"
// "+y3);
double height = distanceBetweenPoints(mid_point[0], mid_point[1], x3, y3);
double wight = distanceBetweenPoints(x1, y1, x2, y2);
// debug(height+" "+wight);
return (height * wight) / 2;
}
private static double distanceBetweenPoints(double x1, double y1, double x2, double y2) {
double x = x2 - x1;
double y = y2 - y1;
return (Math.pow(x, 2) + Math.pow(y, 2));
}
private static double[] midOfaLine(double x1, double y1, double x2, double y2) {
double[] mid = new double[2];
mid[0] = (x1 + x2) / 2;
mid[1] = (y1 + y2) / 2;
return mid;
}
/* Function to calculate x raised to the power y in O(logn) */
static long power(long x, long y) {
long temp;
if (y == 0)
return 1l;
temp = power(x, y / 2);
if (y % 2 == 0)
return (temp * temp);
else
return (x * temp * temp);
}
private static StringBuilder reverseString(String s) {
StringBuilder sb = new StringBuilder(s);
int l = 0, r = sb.length() - 1;
while (l <= r) {
char ch = sb.charAt(l);
sb.setCharAt(l, sb.charAt(r));
sb.setCharAt(r, ch);
l++;
r--;
}
return sb;
}
private static void swap(List<Integer> li, int i, int j) {
int t = li.get(i);
li.set(i, li.get(j));
li.set(j, t);
}
private static void swap(int[] arr, int i, int j) {
int t = arr[i];
arr[i] = arr[j];
arr[j] = t;
}
static int lcm(int a, int b) {
return (a / gcd(a, b)) * b;
}
static long lcm(long a, long b) {
return (a / gcd(a, b)) * b;
}
private static boolean isPallindrome(String s, int l, int r) {
while (l < r) {
if (s.charAt(l) != s.charAt(r))
return false;
l++;
r--;
}
return true;
}
private static StringBuilder removeLeadingZero(StringBuilder sb) {
int i = 0;
while (i < sb.length() && sb.charAt(i) == '0')
i++;
// debug("remove "+i);
if (i == sb.length())
return new StringBuilder();
return new StringBuilder(sb.substring(i, sb.length()));
}
private static void print(int[][] arr) {
int n = arr.length;
int m = arr[0].length;
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
out.print(arr[i][j] + " ");
}
out.println();
}
}
private static StringBuilder removeEndingZero(StringBuilder sb) {
int i = sb.length() - 1;
while (i >= 0 && sb.charAt(i) == '0')
i--;
if (i < 0)
return new StringBuilder();
return new StringBuilder(sb.substring(0, i + 1));
}
private static void debug(int[][] arr) {
for (int i = 0; i < arr.length; i++) {
err.println(Arrays.toString(arr[i]));
}
}
private static void debug(long[][] arr) {
for (int i = 0; i < arr.length; i++) {
err.println(Arrays.toString(arr[i]));
}
}
private static void debug(List<int[]> arr) {
for (int[] a : arr) {
err.println(Arrays.toString(a));
}
}
private static void debug(float[][] arr) {
for (int i = 0; i < arr.length; i++) {
err.println(Arrays.toString(arr[i]));
}
}
private static void debug(double[][] arr) {
for (int i = 0; i < arr.length; i++) {
err.println(Arrays.toString(arr[i]));
}
}
private static void debug(boolean[][] arr) {
for (int i = 0; i < arr.length; i++) {
err.println(Arrays.toString(arr[i]));
}
}
// private static void print() throws IOException {
// out.println(s);
// }
private static void debug(String s) throws IOException {
err.println(s);
}
private static void print(double s) throws IOException {
out.println(s);
}
private static void print(float s) throws IOException {
out.println(s);
}
private static void print(long s) throws IOException {
out.println(s);
}
private static void print(int s) throws IOException {
out.println(s);
}
private static void debug(double s) throws IOException {
err.println(s);
}
private static void debug(float s) throws IOException {
err.println(s);
}
private static void debug(long s) {
err.println(s);
}
private static void debug(int s) {
err.println(s);
}
private static boolean isPrime(long n) {
// Check if number is less than
// equal to 1
if (n <= 1)
return false;
// Check if number is 2
else if (n == 2)
return true;
// Check if n is a multiple of 2
else if (n % 2 == 0)
return false;
// If not, then just check the odds
for (int i = 3; i * i <= n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
private static List<List<Integer>> readUndirectedGraph(int n) {
List<List<Integer>> graph = new ArrayList<>();
for (int i = 0; i <= n; i++) {
graph.add(new ArrayList<>());
}
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
graph.get(x).add(y);
graph.get(y).add(x);
}
return graph;
}
private static List<List<Integer>> readUndirectedGraph(int[][] intervals, int n) {
List<List<Integer>> graph = new ArrayList<>();
for (int i = 0; i <= n; i++) {
graph.add(new ArrayList<>());
}
for (int i = 0; i < intervals.length; i++) {
int x = intervals[i][0];
int y = intervals[i][1];
graph.get(x).add(y);
graph.get(y).add(x);
}
return graph;
}
private static List<List<Integer>> readDirectedGraph(int[][] intervals, int n) {
List<List<Integer>> graph = new ArrayList<>();
for (int i = 0; i <= n; i++) {
graph.add(new ArrayList<>());
}
for (int i = 0; i < intervals.length; i++) {
int x = intervals[i][0];
int y = intervals[i][1];
graph.get(x).add(y);
// graph.get(y).add(x);
}
return graph;
}
private static List<List<Integer>> readDirectedGraph(int n) {
List<List<Integer>> graph = new ArrayList<>();
for (int i = 0; i <= n; i++) {
graph.add(new ArrayList<>());
}
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
graph.get(x).add(y);
// graph.get(y).add(x);
}
return graph;
}
static String[] readStringArray(int n) {
String[] arr = new String[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.next();
}
return arr;
}
private static Map<Character, Integer> freq(String s) {
Map<Character, Integer> map = new HashMap<>();
for (char c : s.toCharArray()) {
map.put(c, map.getOrDefault(c, 0) + 1);
}
return map;
}
private static Map<Long, Integer> freq(long[] arr) {
Map<Long, Integer> map = new HashMap<>();
for (long x : arr) {
map.put(x, map.getOrDefault(x, 0) + 1);
}
return map;
}
private static Map<Integer, Integer> freq(int[] arr) {
Map<Integer, Integer> map = new HashMap<>();
for (int x : arr) {
map.put(x, map.getOrDefault(x, 0) + 1);
}
return map;
}
static boolean[] sieveOfEratosthenes(long n) {
boolean prime[] = new boolean[(int) n + 1];
for (int i = 2; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++) {
// If prime[p] is not changed, then it is a
// prime
if (prime[p] == true) {
// Update all multiples of p
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
return prime;
}
static int[] sieveOfEratosthenesInt(long n) {
boolean prime[] = new boolean[(int) n + 1];
Set<Integer> li = new HashSet<>();
for (int i = 2; i <= n; i++) {
prime[i] = true;
}
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p) {
prime[i] = false;
}
}
}
for (int i = 0; i <= n; i++) {
if (prime[i])
li.add(i);
}
int[] arr = new int[li.size()];
int i = 0;
for (int x : li) {
arr[i++] = x;
}
return arr;
}
static boolean isMemberAC(int a, int d, int x) {
// If difference is 0, then x must
// be same as a.
if (d == 0)
return (x == a);
// Else difference between x and a
// must be divisible by d.
return ((x - a) % d == 0 && (x - a) / d >= 0);
}
static boolean isMemberAC(long a, long d, long x) {
// If difference is 0, then x must
// be same as a.
if (d == 0)
return (x == a);
// Else difference between x and a
// must be divisible by d.
return ((x - a) % d == 0 && (x - a) / d >= 0);
}
private static void sort(int[] arr) {
int n = arr.length;
List<Integer> li = new ArrayList<>();
for (int x : arr) {
li.add(x);
}
Collections.sort(li);
for (int i = 0; i < n; i++) {
arr[i] = li.get(i);
}
}
private static void sortReverse(int[] arr) {
int n = arr.length;
List<Integer> li = new ArrayList<>();
for (int x : arr) {
li.add(x);
}
Collections.sort(li, Collections.reverseOrder());
for (int i = 0; i < n; i++) {
arr[i] = li.get(i);
}
}
private static void sort(double[] arr) {
int n = arr.length;
List<Double> li = new ArrayList<>();
for (double x : arr) {
li.add(x);
}
Collections.sort(li);
for (int i = 0; i < n; i++) {
arr[i] = li.get(i);
}
}
private static void sortReverse(double[] arr) {
int n = arr.length;
List<Double> li = new ArrayList<>();
for (double x : arr) {
li.add(x);
}
Collections.sort(li, Collections.reverseOrder());
for (int i = 0; i < n; i++) {
arr[i] = li.get(i);
}
}
private static void sortReverse(long[] arr) {
int n = arr.length;
List<Long> li = new ArrayList<>();
for (long x : arr) {
li.add(x);
}
Collections.sort(li, Collections.reverseOrder());
for (int i = 0; i < n; i++) {
arr[i] = li.get(i);
}
}
private static void sort(long[] arr) {
int n = arr.length;
List<Long> li = new ArrayList<>();
for (long x : arr) {
li.add(x);
}
Collections.sort(li);
for (int i = 0; i < n; i++) {
arr[i] = li.get(i);
}
}
private static long sum(int[] arr) {
long sum = 0;
for (int x : arr) {
sum += x;
}
return sum;
}
private static long sum(long[] arr) {
long sum = 0;
for (long x : arr) {
sum += x;
}
return sum;
}
private static void initializeIO() {
try {
System.setIn(new FileInputStream("input.txt"));
System.setOut(new PrintStream(new FileOutputStream("output.txt")));
System.setErr(new PrintStream(new FileOutputStream("error.txt")));
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
private static int maxOfArray(int[] arr) {
int max = Integer.MIN_VALUE;
for (int x : arr) {
max = Math.max(max, x);
}
return max;
}
private static long maxOfArray(long[] arr) {
long max = Long.MIN_VALUE;
for (long x : arr) {
max = Math.max(max, x);
}
return max;
}
private static int[][] readIntIntervals(int n, int m) {
int[][] arr = new int[n][m];
for (int j = 0; j < n; j++) {
for (int i = 0; i < m; i++) {
arr[j][i] = sc.nextInt();
}
}
return arr;
}
private static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
private static int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
private static int[] readIntArray(int n) {
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
return arr;
}
private static double[] readDoubleArray(int n) {
double[] arr = new double[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextDouble();
}
return arr;
}
private static long[] readLongArray(int n) {
long[] arr = new long[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextLong();
}
return arr;
}
private static void print(int[] arr) throws IOException {
out.println(Arrays.toString(arr));
}
private static void print(long[] arr) throws IOException {
out.println(Arrays.toString(arr));
}
private static void print(String[] arr) throws IOException {
out.println(Arrays.toString(arr));
}
private static void print(double[] arr) throws IOException {
out.println(Arrays.toString(arr));
}
private static void debug(String[] arr) {
err.println(Arrays.toString(arr));
}
private static void debug(Boolean[][] arr) {
for (int i = 0; i < arr.length; i++)
err.println(Arrays.toString(arr[i]));
}
private static void debug(int[] arr) {
err.println(Arrays.toString(arr));
}
private static void debug(long[] arr) {
err.println(Arrays.toString(arr));
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
static class Tree {
List<List<Integer>> adj = new ArrayList<>();
int parent = 1;
int[] arr;
int n;
Map<Integer, Integer> node_parent;
List<Integer> leaf;
public Tree(int n) {
this.n = n;
leaf = new ArrayList<>();
node_parent = new HashMap<>();
arr = new int[n + 2];
for (int i = 0; i <= n + 1; i++) {
adj.add(new ArrayList<>());
}
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
node_parent.put(i + 1, arr[i]);
if ((i + 1) == arr[i])
parent = arr[i];
else
adj.get(arr[i]).add(i + 1);
}
}
private List<List<Integer>> getTree() {
return adj;
}
private void formLeaf(int v) {
boolean leaf = true;
for (int x : adj.get(v)) {
formLeaf(x);
leaf = false;
}
if (leaf)
this.leaf.add(v);
}
private List<Integer> getLeaf() {
return leaf;
}
private Map<Integer, Integer> getParents() {
return node_parent;
}
int[] getArr() {
return arr;
}
}
static class Dsu {
int[] parent, size;
Dsu(int n) {
parent = new int[n + 1];
size = new int[n + 1];
for (int i = 0; i <= n; i++) {
parent[i] = i;
size[i] = 1;
}
}
private int findParent(int u) {
if (parent[u] == u)
return u;
return parent[u] = findParent(parent[u]);
}
private boolean union(int u, int v) {
// System.out.println("uf "+u+" "+v);
int pu = findParent(u);
// System.out.println("uf2 "+pu+" "+v);
int pv = findParent(v);
// System.out.println("uf3 " + u + " " + pv);
if (pu == pv)
return false;
if (size[pu] <= size[pv]) {
parent[pu] = pv;
size[pv] += size[pu];
} else {
parent[pv] = pu;
size[pu] += size[pv];
}
return true;
}
}
// ===================================================================================
public static int log2(int N) {
return (int) (Math.log(N) / Math.log(2));
}
private static long fact(long n) {
if (n <= 2)
return n;
return n * fact(n - 1);
}
private static void print(String s) throws IOException {
out.println(s);
}
public static boolean isNumeric(String strNum) {
if (strNum == null) {
return false;
}
try {
double d = Double.parseDouble(strNum);
} catch (NumberFormatException nfe) {
return false;
}
return true;
}
private static boolean isSorted(List<Integer> li) {
int n = li.size();
if (n <= 1)
return true;
for (int i = 0; i < n - 1; i++) {
if (li.get(i) > li.get(i + 1))
return false;
}
return true;
}
private static boolean isSorted(int[] arr) {
int n = arr.length;
if (n <= 1)
return true;
for (int i = 0; i < n - 1; i++) {
if (arr[i] > arr[i + 1])
return false;
}
return true;
}
private static boolean ispallindromeList(List<Integer> res) {
int l = 0, r = res.size() - 1;
while (l < r) {
if (res.get(l) != res.get(r))
return false;
l++;
r--;
}
return true;
}
private static long ncr(long n, long r) {
return fact(n) / (fact(r) * fact(n - r));
}
private static void swap(char[] s, int i, int j) {
char t = s[i];
s[i] = s[j];
s[j] = t;
}
static boolean isPowerOfTwo(long x) {
return x != 0 && ((x & (x - 1)) == 0);
}
private static long gcd(long[] arr) {
long ans = 0;
for (long x : arr) {
ans = gcd(x, ans);
}
return ans;
}
private static int gcd(int[] arr) {
int ans = 0;
for (int x : arr) {
ans = gcd(x, ans);
}
return ans;
}
private static long power(long x, long y, long p) {
long res = 1;
x = x % p;
if (x == 0)
return 0;
while (y > 0) {
if ((y & 1) != 0)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 222a0cd3bd94b8c9791d48a45841b588 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0)
{
int n=sc.nextInt();
int l=sc.nextInt();
int r=sc.nextInt();
int d=r-l+1;
boolean f=true;
for(int i=0;i<n;i++)
{
int x=r-r%(i+1);
if(x>=l && x<=r)
{
f=true;
}
else
{
f=false;
break;
}
}
if(f==false)
System.out.println("NO");
else
{
System.out.println("YES");
for(int i=0;i<n;i++)
{
int x=r-r%(i+1);
System.out.print(x+" ");
}
System.out.println();
}
t--;
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 44d58b981a44ed9774fa60fb901410e8 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
static final int INF = 0x3f3f3f3f;
static final long LNF = 0x3f3f3f3f3f3f3f3fL;
public static void main(String[] args) throws IOException {
initReader();
int t=nextInt();
while (t--!=0){
int n=nextInt();
int l=nextInt();
int r=nextInt();
int[]arr=new int[n+1];
int id=1;
for(int i=1;i<=n;i++) {
int s=l/i;
if(l%i!=0)s++;
if(s*i<=r)
arr[id++] = s*i;
}
if(id==n+1){
pw.println("YES");
for(int j=1;j<=n;j++){
pw.print(arr[j]+" ");
}
pw.println();
}else {
pw.println("NO");
}
}
pw.close();
}
/***************************************************************************************/
static BufferedReader reader;
static StringTokenizer tokenizer;
static PrintWriter pw;
public static void initReader() throws IOException {
reader = new BufferedReader(new InputStreamReader(System.in));
tokenizer = new StringTokenizer("");
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
// 从文件读写
// reader = new BufferedReader(new FileReader("test.in"));
// tokenizer = new StringTokenizer("");
// pw = new PrintWriter(new BufferedWriter(new FileWriter("test1.out")));
}
public static boolean hasNext() {
try {
while (!tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(reader.readLine());
}
} catch (Exception e) {
return false;
}
return true;
}
public static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
public static String nextLine() {
try {
return reader.readLine();
} catch (Exception e) {
return null;
}
}
public static int nextInt() throws IOException {
return Integer.parseInt(next());
}
public static long nextLong() throws IOException {
return Long.parseLong(next());
}
public static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public static char nextChar() throws IOException {
return next().charAt(0);
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 70058bb210cfa9e0c44eec8de1dbcccb | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | /*
IF I HAD CHOICE, I WOULD HAVE BEEN A PIRATE, LOL XD ;
_____________#############
_____________##___________##
______________#____________#
_______________#____________#_##
_______________#__###############
_____##############______________#
_____##____________#_____################
______#______##############______________#
______##_____##___________#______________##
_______#______#____PARTH___#______________#
______##_______#___________##____________#
______###########__________##___________##
___________#_#_##________###_____########_____###
___________#_#_###########_#######_______#####__#########
######_____#_#______##_#_______#_#########___########
##___#########______##_#____#######________#####
__##________##################____##______###
____#____________________________##_#____##
_____#_____###_____##_____###_____###___##
______#___##_##___##_#____#_##__________#
______##____##_____###_____##__________##
________##___________________________##
___________#########################
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main2 {
static PrintWriter out = new PrintWriter(System.out);
static FastReader sc = new FastReader();
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args)
{
int tes = sc.nextInt();
while(tes-->0){
solve();
}
out.close();
}
private static void solve() {
int n = sc.nextInt();
long a = sc.nextLong();
long b = sc.nextLong();
long [] arr = new long[n];
for (int i = 1; i <= n; i++) {
long x=(b/i)*i;
if(x<a){
out.println("NO");
return;
}
else{
arr[i-1]= (int) x;
}
}
out.println("YES");
for (int i = 0; i < n ; i++) out.print(arr[i]+" ");
out.println();
}
}
/* Test case 0 :-
*/ | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | c28f306ea88b048b01aea9762927b576 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class file{
public static int LCM(int n1, int n2) {
int GCD = GCD(n1, n2);
return (n1 * n2) / GCD;
}
public static int GCD(int n1, int n2) {
while(n1 % n2 != 0) {
int rem = n1 % n2;
n1 = n2;n2 = rem;
}
return n2;
}
private static void helper(int n, int ind) {
if(ind == 1) {
for(int i = 0;i < n-1;i++) System.out.print(" ");
System.out.print("*");
System.out.println();
return;
}
helper(n, ind - 1);
for(int i = ind;i < n;i++) System.out.print(" ");
for(int i = 0;i < (2 * ind - 1);i++) System.out.print("*");
// for(int i = ind;i < n;i++) System.out.print(" ");
System.out.println();
}
private static long helper(int ind, int k, int[][] arr, long[][] dp) {
if(ind == arr.length) return 0;
if(dp[ind][k] != -1) return dp[ind][k];
long left = helper(ind + 1, k, arr, dp);
long right = Integer.MIN_VALUE;
if(arr[ind][0] <= k) right = helper(ind + 1, k - (int)arr[ind][0], arr, dp) + (long)arr[ind][1];
return dp[ind][k] = Math.max(left, right);
}
static int count=0;
public static void dfs(int sv, boolean[] vis, HashMap<Integer, List<Integer>> map) {
vis[sv] = true;
count++;
List<Integer> arr= map.get(sv);
if(arr == null) return;
for(int i = 0;i < arr.size();i++) {
int node = arr.get(i);
if(!vis[node]) {
dfs(node, vis, map);
}
}
}
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
int mod = 1000000007;
// helper(n, n);
// scan.nextLine();
for(int x = 1;x <= t;x++) {
int n = scan.nextInt();
int l = scan.nextInt();
int r = scan.nextInt();
// if(n == 1) {
// System.out.println("YES");
// System.out.println(l);
// continue;
// }
List<Long> arr = new ArrayList<>();
boolean ach = true;
for(int i = n;i >= 1;i--) {
boolean ach2 = false;
long num = l, count=0;
HashMap<Long, Integer> map = new HashMap<>();
while(!ach2) {
num = (num % i == 0) ?((num == i && count == 0) || count == 0) ? num: num + i:num + (i - (num % i));
count++;
if(num > r) break;
if(map.containsKey(num)) continue;
arr.add(num);
map.put(num, 0);
ach2=true;
}
if(!ach2) {
ach = false;break;
}
}
if(!ach) {
System.out.println("NO");
continue;
}
System.out.println("YES");
for(int i = n-1;i >= 0;i--) {
System.out.print(arr.get(i) + " ");
}
System.out.println();
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | f71830deb7628b18d8b9856f39a6e75c | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class TestingArea{
public static void main(String[] args) throws IOException{
BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
PrintWriter out=new PrintWriter(System.out);
int t=Integer.parseInt(f.readLine());
while(t-->0) {
StringTokenizer st=new StringTokenizer(f.readLine());
int n=Integer.parseInt(st.nextToken());
int l=Integer.parseInt(st.nextToken());
int r=Integer.parseInt(st.nextToken());
StringBuffer sb=new StringBuffer();
boolean good=true;
for(int i=1;i<=n;i++) {
if(l%i==0) {
sb.append(l+" ");
}
else {
if(((l/i)+1)*i>r) {
out.println("NO");
good=false;
break;
}
else {
sb.append(((l/i)+1)*i+" ");
}
}
}
if(good) {
out.println("YES");
out.println(sb.toString());
}
}
out.close();
f.close();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 5e438fe64d38fa7c67f460c545c1d06c | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static long M = (long) (1e9 + 7);
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
if (st.hasMoreTokens()) {
str = st.nextToken("\n");
} else {
str = br.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void heapify(int arr[], int n, int i) {
int largest = i;
int l = 2 * i + 1;
int r = 2 * i + 2;
if (l < n && arr[l] > arr[largest])
largest = l;
if (r < n && arr[r] > arr[largest])
largest = r;
if (largest != i) {
int swap = arr[i];
arr[i] = arr[largest];
arr[largest] = swap;
heapify(arr, n, largest);
}
}
public static void swap(int[] a, int i, int j) {
int temp = (int) a[i];
a[i] = a[j];
a[j] = temp;
}
public static int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
public static int lcm(int a, int b) {
return (a * b / gcd(a, b));
}
public static String sortString(String inputString) {
// Converting input string to character array
char[] tempArray = inputString.toCharArray();
// Sorting temp array using
Arrays.sort(tempArray);
// Returning new sorted string
return new String(tempArray);
}
static boolean isSquare(int n) {
int v = (int) Math.sqrt(n);
return v * v == n;
}
static boolean PowerOfTwo(int n) {
if (n == 0) return false;
return (int) (Math.ceil((Math.log(n) / Math.log(2)))) ==
(int) (Math.floor(((Math.log(n) / Math.log(2)))));
}
static int power(long a, long b) {
long res = 1;
while (b > 0) {
if (b % 2 == 1) {
res = (res * a) % M;
}
a = ((a * a) % M);
b = b / 2;
}
return (int) res;
}
public static boolean isPrime(int n) {
for (int i = 2; i * i <= n; i++)
if (n % i == 0) {
return false;
}
return true;
}
static int pown(long n) {
if (n == 0)
return 1;
if (n == 1)
return 1;
if ((n & (~(n - 1))) == n)
return 0;
return 1;
}
static long computeXOR(long n) {
// If n is a multiple of 4
if (n % 4 == 0)
return n;
// If n%4 gives remainder 1
if (n % 4 == 1)
return 1;
// If n%4 gives remainder 2
if (n % 4 == 2)
return n + 1;
// If n%4 gives remainder 3
return 0;
}
static long binaryToInteger(String binary) {
char[] numbers = binary.toCharArray();
long result = 0;
for (int i = numbers.length - 1; i >= 0; i--)
if (numbers[i] == '1')
result += Math.pow(2, (numbers.length - i - 1));
return result;
}
static String reverseString(String str) {
char ch[] = str.toCharArray();
String rev = "";
for (int i = ch.length - 1; i >= 0; i--) {
rev += ch[i];
}
return rev;
}
static int countFreq(int[] arr, int n) {
HashMap<Integer, Integer> map = new HashMap<>();
int x = 0;
for (int i = 0; i < n; i++) {
map.put(arr[i], map.getOrDefault(arr[i], 0) + 1);
}
for (int i = 0; i < n; i++) {
if (map.get(arr[i]) == 1)
x++;
}
return x;
}
static boolean symm(String str) {
if (str.length() == 1 || str.length() == 0)
return true;
if (str.substring(0, (str.length() / 2)).equals(str.substring(str.length() / 2)))
return symm(str.substring(0, (str.length() / 2)));
return false;
}
static void reverse(int[] arr, int l, int r)
{
int d = (r-l+1)/2;
for(int i=0;i<d;i++)
{
int t = arr[l+i];
arr[l+i] = arr[r-i];
arr[r-i] = t;
}
// print array here
}
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
int t = sc.nextInt();
while (t-- != 0) {
long a = sc.nextLong();
long b = sc.nextLong();
long c = sc.nextLong();
int[] arr = new int[(int) a + 1];
long max = 0;
for (int i = 1; i <= a; i++) {
long m = b / i;
if (m * i < b)
m++;
arr[i] = (int) (i * m);
max = Math.max(arr[i], max);
}
if (max > c) {
System.out.println("NO");
} else {
System.out.println("YES");
for (int i = 1; i <= a; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
}
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | f0c39307aa169767af0b2d987cea9f26 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class _cf {
public static void main (String[] args) { new _cf(); }
public _cf() {
Scanner s = new Scanner();
PrintWriter out = new PrintWriter(System.out);
int T = s.nextInt();
while(T-- > 0) {
int n = s.nextInt();
int L = s.nextInt();
int R = s.nextInt();
int[] res = new int[n + 1];
boolean impossible = false;
for(int i = n; i >= 1; i--) {
int start = L + ((i - (L % i))%i);
if (start > R) {
impossible = true;
break;
}
res[i] = start;
}
if (impossible) {
out.println("NO");
}
else {
//HashSet<Integer> set = new HashSet<>();
out.println("YES");
for(int i = 1; i <= n; i++) {
if(i > 1) out.print(" ");
// int x = gcd(i, res[i]);
// if (set.contains(x)) System.out.println(1/0);
// else set.add(x);
out.print(res[i]);
}
out.println();
}
}
out.close();
}
int gcd(int a, int b) {
if(b == 0) return a;
return gcd(b, a % b);
}
class Scanner {
public int BS = 1<<16;
public char NC = (char)0;
byte[] buf = new byte[BS];
int bId = 0, size = 0;
char c = NC;
double num = 1;
BufferedInputStream in;
public Scanner() {
in = new BufferedInputStream(System.in, BS);
}
public Scanner(String s) {
try {
in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
}
catch (Exception e) {
in = new BufferedInputStream(System.in, BS);
}
}
public char nextChar(){
while(bId==size) {
try {
size = in.read(buf);
}catch(Exception e) {
return NC;
}
if(size==-1)return NC;
bId=0;
}
return (char)buf[bId++];
}
public int nextInt() {
return (int)nextLong();
}
public long nextLong() {
num=1;
boolean neg = false;
if(c==NC)c=nextChar();
for(;(c<'0' || c>'9'); c = nextChar()) {
if(c=='-')neg=true;
}
long res = 0;
for(; c>='0' && c <='9'; c=nextChar()) {
res = (res<<3)+(res<<1)+c-'0';
num*=10;
}
return neg?-res:res;
}
public double nextDouble() {
double cur = nextLong();
return c!='.' ? cur:cur+nextLong()/num;
}
public String next() {
StringBuilder res = new StringBuilder();
while(c<=32)c=nextChar();
while(c>32) {
res.append(c);
c=nextChar();
}
return res.toString();
}
public String nextLine() {
StringBuilder res = new StringBuilder();
while(c<=32)c=nextChar();
while(c!='\n') {
res.append(c);
c=nextChar();
}
return res.toString();
}
public boolean hasNext() {
if(c>32)return true;
while(true) {
c=nextChar();
if(c==NC)return false;
else if(c>32)return true;
}
}
public int[] nextIntArray(int n) {
int[] res = new int[n];
for(int i = 0; i < n; i++) res[i] = nextInt();
return res;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 6b800fa6fd91c3ee25b87ea30541525b | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class DifferenceOfGCDs{
public static String solve(int n, int l, int r){
// if(r - l + 1 < n) return "NO\n";
int res[] = new int[n];
Set<Integer> set = new HashSet<>();
for(int i=n; i>0; i--){
int temp = r / i * i;
if(temp < l) return "NO\n";
res[i-1] = temp;
set.add(temp);
}
StringBuilder sb = new StringBuilder("YES\n");
for(int i=0; i<n; i++){
sb.append(res[i]+" ");
}
sb.append("\n");
return sb.toString();
}
public static void main(String args[])throws IOException{
Scanner sc = new Scanner(System.in);
int tests = sc.nextInt();
while( tests --> 0 ){
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
String res = solve(n, l, r);
System.out.printf("%s", res);
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | e8b93a049a578082778241d1cb47e0ae | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/* Name of the class has to be "Main" only if the class is public. */
public class C
{
static short m_short = Short.MAX_VALUE;
static Scanner sc= new Scanner(System.in);
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
int t=sc.nextInt();
while(t-->0)
solve();
}
static final long modulo = 1000000007;
static int res=0;
static int mod = (int)Math.pow(10,9)+7;
// static int c[];
public static void solve() {
// DataInputStream ds= new DataInputStream(System.in);
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// long supreme = 100000;
int n=sc.nextInt();
int left = sc.nextInt();
int right=sc.nextInt();
int[] a = new int[n];
//String a =sc.next();
//String b=sc.next();
// char [][] a = new char[n][n];
// int[] b = new int[n+1];
// int[] b = new int[n+11];
HashMap<String,Integer> map = new HashMap<>();
int ans=-1;
for(int i=0;i<10;i++)
ans&=i;
int rs=1;
// List<Long> nn = new AanswertaskayList<>(n);
for(int x=-1;x>10;x+=5)
ans++;
// int ptr=n-1;
int z=3;
int sum=0;
// for(int i=0;i<n;i++){
// a[i]=sc.nextInt();
// sum+=a[i];
// }
// Arrays.sort(a);
int currops=0;
// if(n>(right-left+1)){
// System.out.println("NO");
// return;
// }
for(int i=1;i<=n;i++){
double xx=(Math.ceil((left*1.0/i)))*i;
if(right<xx){
System.out.println("NO");
return;
}
a[i-1]=(int)xx;
}
System.out.print("YES"+"\n");
for(int i=0;i<n;i++){
System.out.print(a[i]+" ");
}
System.out.println();
}
public static void swap(int[] a , int i ,int j){
int temp = a[i];
a[i]=a[j];
a[j]=temp;
}
public static int reverseN(int n){
int rev=0;
while(n>0){
rev = rev*10+n%10;
n/=10;
}
return rev;
}
public static boolean palin(char[] ch , int i ,int j){
while(i<=j){
if(ch[i]!=ch[j])
return false;
}
return true;
}
// public static void dfs(StringBuilder s,int[][] que,int i){
// if(i==que.length) return;
// s.append(s.substring(que[i][0]-1,que[i][1]));
// dfs(s,que,i+1);
// }
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | cec3dd2910610236f912e2ab8bd07ddf | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | // B. Difference of GCDs
import java.util.*;
import java.lang.*;
import java.io.*;
public final class Main {
FastReader s;
// PrintWriter out ;
public static void main(String[] args) throws java.lang.Exception {
new Main().run();
}
void run() {
// out = new PrintWriter(new OutputStreamWriter(System.out));
s = new FastReader();
solve();
}
StringBuffer sb;
void solve() {
sb = new StringBuffer();
for (int T = s.nextInt(); T > 0; T--) {
start();
}
System.out.print(sb);
}
void start() {
int n = s.nextInt();
long l = s.nextLong();
long r = s.nextLong();
int cnt = 0;
int ans[] = new int[n+1];
ans[1] = (int)l;
boolean p = true;
for(long i = 2; i<=n; i++)
{
if(l >= i)
{
long g = l%i;
if(g == 0)
{
ans[(int)i] = (int)l;
}
else if(((i-g)+l) <=r)
{
ans[(int)i] = (int)((i-g)+l);
}
else
{
p = false;
sb.append("NO\n");
return;
}
}
else
{
if(i<=r)
{
ans[(int)i] = (int)i;
}
else
{
p = false;
sb.append("NO\n");
return;
}
}
}
if(p)
{
sb.append("YES\n");
for(int i=1; i<=n; i++)
{
sb.append(ans[i]+" ");
}
sb.append("\n");
}
else {
sb.append("NO\n");
}
}
ArrayList<Long> fac(long j)
{
ArrayList<Long> f = new ArrayList<>();
for(long k = 1; k*k<=j; k++)
{
if(j%k == 0 )
{
f.add(k);
if(j/k != k)
f.add(j/k);
}
}
return f;
}
void swap(int arr[], int i, int j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
class Pair {
int x;
int y;
// String hash;
public Pair(int x, int y) {
this.x = x;
this.y = y;
// this.hash = x+" "+y;
}
@Override
public String toString() {
return ("{ x = " + this.x + " , " + "y = " + this.y + " }");
}
@Override
public boolean equals(Object ob) {
if (this == ob)
return true;
if (ob == null || this.getClass() != ob.getClass())
return false;
Pair p = (Pair) ob;
return (p.x == this.x) && (p.y == this.y);
}
// @Override
// public int hashCode()
// {
// return hash.hashCode();
// }
}
class LongPair {
long x;
long y;
// String hash;
public LongPair(long x, long y) {
this.x = x;
this.y = y;
// this.hash = x+" "+y;
}
@Override
public String toString() {
return ("{ x = " + this.x + " , " + "y = " + this.y + " }");
}
@Override
public boolean equals(Object ob) {
if (this == ob)
return true;
if (ob == null || this.getClass() != ob.getClass())
return false;
LongPair p = (LongPair) ob;
return (p.x == this.x) && (p.y == this.y);
}
// @Override
// public int hashCode()
// {
// return hash.hashCode();
// }
}
class SegmentTree {
int[] tree;
int n;
public SegmentTree(int[] nums) {
if (nums.length > 0) {
n = nums.length;
tree = new int[n * 2];
buildTree(nums);
}
}
private void buildTree(int[] nums) {
for (int i = n, j = 0; i < 2 * n; i++, j++)
tree[i] = nums[j];
for (int i = n - 1; i > 0; --i)
tree[i] = tree[i * 2] + tree[i * 2 + 1];
}
void update(int pos, int val) {
pos += n;
tree[pos] = val;
while (pos > 0) {
int left = pos;
int right = pos;
if (pos % 2 == 0) {
right = pos + 1;
} else {
left = pos - 1;
}
// parent is updated after child is updated
tree[pos / 2] = tree[left] + tree[right];
pos /= 2;
}
}
public int sumRange(int l, int r) {
// get leaf with value 'l'
l += n;
// get leaf with value 'r'
r += n;
int sum = 0;
while (l <= r) {
if ((l % 2) == 1) {
sum += tree[l];
l++;
}
if ((r % 2) == 0) {
sum += tree[r];
r--;
}
l /= 2;
r /= 2;
}
return sum;
}
}
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
long power(long x, long y, long p) {
long res = 1;
x = x % p;
while (y > 0) {
if ((y & 1) > 0)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
int find(int dsu[], int i) {
if (dsu[i] == i)
return i;
dsu[i] = find(dsu, dsu[i]);
return dsu[i];
}
void union(int dsu[], int i, int j) {
int a = find(dsu, i);
int b = find(dsu, j);
dsu[a] = b;
}
static void sort(int[] a) {
ArrayList<Integer> l = new ArrayList<>();
for (int i : a)
l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++)
a[i] = l.get(i);
}
static void sort(long[] a) {
ArrayList<Long> l = new ArrayList<>();
for (long i : a)
l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++)
a[i] = l.get(i);
}
static String sort(String s) {
Character ch[] = new Character[s.length()];
for (int i = 0; i < s.length(); i++) {
ch[i] = s.charAt(i);
}
Arrays.sort(ch);
StringBuffer st = new StringBuffer("");
for (int i = 0; i < s.length(); i++) {
st.append(ch[i]);
}
return st.toString();
}
// long array input
public long[] longArr(int len) {
// long arr input
long[] arr = new long[len];
String[] strs = s.nextLine().trim().split("\\s+");
for (int i = 0; i < len; i++) {
arr[i] = Long.parseLong(strs[i]);
}
return arr;
}
// int arr input
public int[] intArr(int len) {
// long arr input
int[] arr = new int[len];
String[] strs = s.nextLine().trim().split("\\s+");
for (int i = 0; i < len; i++) {
arr[i] = Integer.parseInt(strs[i]);
}
return arr;
}
public void printArray(int[] A) {
System.out.println(Arrays.toString(A));
}
public void printArray(long[] A) {
System.out.println(Arrays.toString(A));
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 254f692e246c75ae8780b2ebe5dedb96 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main2 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int testcase = Integer.parseInt(br.readLine());
C:while(testcase-->0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int length = Integer.parseInt(st.nextToken());
int min = Integer.parseInt(st.nextToken());
int max = Integer.parseInt(st.nextToken());
int[] result = new int[length+1];
Arrays.fill(result, -1);
for (int i=2;i<result.length;i++) {
int start = min / i;
for (;start * i <= max; start++) {
if (start * i >= min) {
result[i] = start*i;
break;
}
}
}
result[1] = min;
for (int i=1;i<result.length;i++) {
if (result[i]==-1) {
bw.write("NO\n");
continue C;
}
}
bw.write("YES\n");
for (int i=1;i<result.length;i++) {
bw.write(result[i]+" ");
}
bw.write('\n');
}
bw.flush();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | e4ea650d5c0eb547b45db8bac2db3272 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.Scanner;
public class DifferenceOfGcd {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t= in.nextInt();
for (int i = 0; i < t; i++) {
int n=in.nextInt();
int l=in.nextInt();
int r=in.nextInt();
int d=r-l+1;
int ar[]=new int[n];
boolean flag=true;
for (int k = 1; k <=n ; k++) {
int n1=l/k;
int n2=l%k;
int n3=0;
if(n2>0){
n3=k-n2;}
if(n3>r-l){
flag=false;
break;
}
ar[k-1]=l+n3;
}
if(flag){
System.out.println("YES");
for(int j:ar) System.out.print(j+" ");
System.out.println();
}
else{
System.out.println("NO");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 92653742df1097811c49427adfe19bb8 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | /*
Author: Spidey2182
#: 1708B
*/
import java.util.*;
public class DifferenceOfGCDs {
static ContestScanner sc = new ContestScanner();
static ContestPrinter out = new ContestPrinter();
public static void main(String[] args) {
int n, l, r;
int testCases=sc.nextInt();
while(testCases-->0) {
n=sc.nextInt();
l=sc.nextInt();
r=sc.nextInt();
int[] a=new int[n];
for (int i = 0; i < n; i++) {
a[i]=(int)(Math.ceil(1.0*l/(i+1))*(i+1));
if(a[i]>r) {
out.println("NO");
break;
}
}
if(a[n-1]==0 || a[n-1]>r)
continue;
out.println("YES");
out.printArray(a);
}
out.flush();
out.close();
}
static final int MOD = (int) 1e9 + 7;
//Credits: https://github.com/NASU41/AtCoderLibraryForJava/tree/master/ContestIO
static class ContestScanner {
private final java.io.InputStream in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private static final long LONG_MAX_TENTHS = 922337203685477580L;
private static final int LONG_MAX_LAST_DIGIT = 7;
private static final int LONG_MIN_LAST_DIGIT = 8;
public ContestScanner(java.io.InputStream in) {
this.in = in;
}
public ContestScanner(java.io.File file) throws java.io.FileNotFoundException {
this(new java.io.BufferedInputStream(new java.io.FileInputStream(file)));
}
public ContestScanner() {
this(System.in);
}
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (java.io.IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte()) return buffer[ptr++];
else return -1;
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
public boolean hasNext() {
while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
return hasNextByte();
}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
int digit = b - '0';
if (n >= LONG_MAX_TENTHS) {
if (n == LONG_MAX_TENTHS) {
if (minus) {
if (digit <= LONG_MIN_LAST_DIGIT) {
n = -n * 10 - digit;
b = readByte();
if (!isPrintableChar(b)) {
return n;
} else if (b < '0' || '9' < b) {
throw new NumberFormatException(
String.format("%d%s... is not number", n, Character.toString(b))
);
}
}
} else {
if (digit <= LONG_MAX_LAST_DIGIT) {
n = n * 10 + digit;
b = readByte();
if (!isPrintableChar(b)) {
return n;
} else if (b < '0' || '9' < b) {
throw new NumberFormatException(
String.format("%d%s... is not number", n, Character.toString(b))
);
}
}
}
}
throw new ArithmeticException(
String.format("%s%d%d... overflows long.", minus ? "-" : "", n, digit)
);
}
n = n * 10 + digit;
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
return (int) nl;
}
public double nextDouble() {
return Double.parseDouble(next());
}
public long[] nextLongArray(int length) {
long[] array = new long[length];
for (int i = 0; i < length; i++) array[i] = this.nextLong();
return array;
}
public long[] nextLongArray(int length, java.util.function.LongUnaryOperator map) {
long[] array = new long[length];
for (int i = 0; i < length; i++) array[i] = map.applyAsLong(this.nextLong());
return array;
}
public int[] nextIntArray(int length) {
int[] array = new int[length];
for (int i = 0; i < length; i++) array[i] = this.nextInt();
return array;
}
public int[] nextIntArray(int length, java.util.function.IntUnaryOperator map) {
int[] array = new int[length];
for (int i = 0; i < length; i++) array[i] = map.applyAsInt(this.nextInt());
return array;
}
public double[] nextDoubleArray(int length) {
double[] array = new double[length];
for (int i = 0; i < length; i++) array[i] = this.nextDouble();
return array;
}
public double[] nextDoubleArray(int length, java.util.function.DoubleUnaryOperator map) {
double[] array = new double[length];
for (int i = 0; i < length; i++) array[i] = map.applyAsDouble(this.nextDouble());
return array;
}
public long[][] nextLongMatrix(int height, int width) {
long[][] mat = new long[height][width];
for (int h = 0; h < height; h++)
for (int w = 0; w < width; w++) {
mat[h][w] = this.nextLong();
}
return mat;
}
public int[][] nextIntMatrix(int height, int width) {
int[][] mat = new int[height][width];
for (int h = 0; h < height; h++)
for (int w = 0; w < width; w++) {
mat[h][w] = this.nextInt();
}
return mat;
}
public double[][] nextDoubleMatrix(int height, int width) {
double[][] mat = new double[height][width];
for (int h = 0; h < height; h++)
for (int w = 0; w < width; w++) {
mat[h][w] = this.nextDouble();
}
return mat;
}
public char[][] nextCharMatrix(int height, int width) {
char[][] mat = new char[height][width];
for (int h = 0; h < height; h++) {
String s = this.next();
for (int w = 0; w < width; w++) {
mat[h][w] = s.charAt(w);
}
}
return mat;
}
}
static class ContestPrinter extends java.io.PrintWriter {
public ContestPrinter(java.io.PrintStream stream) {
super(stream);
}
public ContestPrinter(java.io.File file) throws java.io.FileNotFoundException {
super(new java.io.PrintStream(file));
}
public ContestPrinter() {
super(System.out);
}
private static String dtos(double x, int n) {
StringBuilder sb = new StringBuilder();
if (x < 0) {
sb.append('-');
x = -x;
}
x += Math.pow(10, -n) / 2;
sb.append((long) x);
sb.append(".");
x -= (long) x;
for (int i = 0; i < n; i++) {
x *= 10;
sb.append((int) x);
x -= (int) x;
}
return sb.toString();
}
@Override
public void print(float f) {
super.print(dtos(f, 20));
}
@Override
public void println(float f) {
super.println(dtos(f, 20));
}
@Override
public void print(double d) {
super.print(dtos(d, 20));
}
@Override
public void println(double d) {
super.println(dtos(d, 20));
}
public void printArray(int[] array, String separator) {
int n = array.length;
if (n == 0) {
super.println();
return;
}
for (int i = 0; i < n - 1; i++) {
super.print(array[i]);
super.print(separator);
}
super.println(array[n - 1]);
}
public void printArray(int[] array) {
this.printArray(array, " ");
}
public void printArray(int[] array, String separator, java.util.function.IntUnaryOperator map) {
int n = array.length;
if (n == 0) {
super.println();
return;
}
for (int i = 0; i < n - 1; i++) {
super.print(map.applyAsInt(array[i]));
super.print(separator);
}
super.println(map.applyAsInt(array[n - 1]));
}
public void printArray(int[] array, java.util.function.IntUnaryOperator map) {
this.printArray(array, " ", map);
}
public void printArray(long[] array, String separator) {
int n = array.length;
if (n == 0) {
super.println();
return;
}
for (int i = 0; i < n - 1; i++) {
super.print(array[i]);
super.print(separator);
}
super.println(array[n - 1]);
}
public void printArray(long[] array) {
this.printArray(array, " ");
}
public void printArray(long[] array, String separator, java.util.function.LongUnaryOperator map) {
int n = array.length;
if (n == 0) {
super.println();
return;
}
for (int i = 0; i < n - 1; i++) {
super.print(map.applyAsLong(array[i]));
super.print(separator);
}
super.println(map.applyAsLong(array[n - 1]));
}
public void printArray(long[] array, java.util.function.LongUnaryOperator map) {
this.printArray(array, " ", map);
}
public <T> void printArray(T[] array, String separator) {
int n = array.length;
if (n == 0) {
super.println();
return;
}
for (int i = 0; i < n - 1; i++) {
super.print(array[i]);
super.print(separator);
}
super.println(array[n - 1]);
}
public <T> void printArray(T[] array) {
this.printArray(array, " ");
}
public <T> void printArray(T[] array, String separator, java.util.function.UnaryOperator<T> map) {
int n = array.length;
if (n == 0) {
super.println();
return;
}
for (int i = 0; i < n - 1; i++) {
super.print(map.apply(array[i]));
super.print(separator);
}
super.println(map.apply(array[n - 1]));
}
public <T> void printArray(T[] array, java.util.function.UnaryOperator<T> map) {
this.printArray(array, " ", map);
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 4b4df7be2653277d61a44b54d881fee9 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
/**
* For deep recursion
*/
public class MainFaster{
void solve(){
int n = scanner.nextInt();
long l = scanner.nextInt();
long r = scanner.nextInt();
long[] res = new long[n];
boolean valid = true;
for(int i = n; i >= 1; i--){
long R = (r / i) * i;
if(R >= l && R <= r){
res[i-1] = R;
}
else{
valid = false;
break;
}
}
if(valid){
out.println("YES");
for(int i = 0; i < res.length; i++){
out.print(res[i]);
out.print(i == res.length-1? '\n':' ');
}
}
else{
out.println("NO");
}
}
boolean isValid(long[] res, long l, long r){
Set<Long> s = new HashSet<>();
for(long val: res){
if(val < l || val > r){
return false;
}
s.add(val);
}
return s.size() == res.length;
}
static long gcdLong(long n1, long n2) {
if (n2 == 0) {
return n1;
}
return gcdLong(n2, n1 % n2);
}
private static final boolean memory = false;
private static final boolean singleTest = false;
// read inputs and call solvers
void run() {
int numOfTests = singleTest? 1: scanner.nextInt();
for(int testIdx = 1; testIdx <= numOfTests; testIdx++){
solve();
}
out.flush();
out.close();
}
public static void main(String[] args) {
if(memory) {
new Thread(null, new Runnable() {
@Override
public void run() {
new MainFaster().run();
}
}, "go", 1 << 26).start();
}
else{
new MainFaster().run();
}
}
/**
* IO utils
*/
public static MyScanner scanner = new MyScanner();
public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[] nextIntArray(int n, int base){
int[] arr = new int[n + base];
for(int i = base; i < n + base; i++){
arr[i] = scanner.nextInt();
}
return arr;
}
long[] nextLongArray(int n, int base){
long[] arr = new long[n + base];
for(int i = base; i < n + base; i++){
arr[i] = scanner.nextLong();
}
return arr;
}
}
void debug(Object...o){
out.println(Arrays.deepToString(o));
}
void print(Object...o) {
for(int i = 0; i < o.length; i++){
out.print(o);
out.print(i == o.length-1? '\n':' ');
}
}
void println(Object ...o){
for(int i = 0; i < o.length; i++){
out.println(o);
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 26fd89d46829a658ae0e318227b34292 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
public class Main {
static BiFunction<Integer, Integer, Integer> ADD = (x, y) -> (x + y);
static BiFunction<ArrayList<Integer>, ArrayList<Integer>, ArrayList<Integer>> ADD_ARRAY_LIST = (x, y) -> {
x.addAll(y);
return x;
};
static Function<Pair<Integer, Integer>, Integer> GET_FIRST = (x) -> (x.first);
static Function<Pair<Integer, Integer>, Integer> GET_SECOND = (x) -> (x.second);
static Comparator<Pair<Integer, Integer>> C = Comparator.comparing(x -> x.first + x.second);
static long MOD = 1_000_000_000 + 7;
public static void main(String[] args) throws Exception {
long startTime = System.nanoTime();
int t = in.nextInt();
while (t-- > 0) {
solve();
}
long endTime = System.nanoTime();
err.println("Execution Time : +" + (endTime - startTime) / 1000000 + " ms");
exit(0);
}
static void solve() {
int n = in.nextInt();
int l = in.nextInt();
int r = in.nextInt();
StringBuilder res = new StringBuilder();
res.append(l);
res.append(" ");
int ans = 1;
for (int i = 2; i <= n; i++) {
for (int j = l / i; j * i <= r; j++) {
if (i * j >= l && i * j <= r) {
res.append(j * i);
res.append(" ");
ans++;
break;
}
}
}
if (ans == n) {
y();
out.println(res);
} else {
n();
}
}
static void debug(Object... args) {
for (Object a : args) {
out.println(a);
}
}
static int dist(Pair<Integer, Integer> a, Pair<Integer, Integer> b) {
return Math.abs(a.first - b.first) + Math.abs(a.second - b.second);
}
static void y() {
out.println("YES");
}
static void n() {
out.println("NO");
}
static int[] stringToArray(String s) {
return s.chars().map(x -> Character.getNumericValue(x)).toArray();
}
static <T> T min(T a, T b, Comparator<T> C) {
if (C.compare(a, b) <= 0) {
return a;
}
return b;
}
static <T> T max(T a, T b, Comparator<T> C) {
if (C.compare(a, b) >= 0) {
return a;
}
return b;
}
static void fail() {
out.println("-1");
}
static class Pair<T, R> {
public T first;
public R second;
public Pair(T first, R second) {
this.first = first;
this.second = second;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final Pair<?, ?> pair = (Pair<?, ?>) o;
return Objects.equals(first, pair.first) && Objects.equals(second, pair.second);
}
@Override
public int hashCode() {
return Objects.hash(first, second);
}
@Override
public String toString() {
return "Pair{" + "a=" + first + ", b=" + second + '}';
}
public T getFirst() {
return first;
}
public R getSecond() {
return second;
}
}
static <T, R> Pair<T, R> make_pair(T a, R b) {
return new Pair<>(a, b);
}
static long mod_inverse(long a, long m) {
Number x = new Number(0);
Number y = new Number(0);
extended_gcd(a, m, x, y);
return (m + x.v % m) % m;
}
static long extended_gcd(long a, long b, Number x, Number y) {
long d = a;
if (b != 0) {
d = extended_gcd(b, a % b, y, x);
y.v -= (a / b) * x.v;
} else {
x.v = 1;
y.v = 0;
}
return d;
}
static class Number {
long v = 0;
public Number(long v) {
this.v = v;
}
}
static long lcm(long a, long b, long c) {
return lcm(a, lcm(b, c));
}
static long lcm(long a, long b) {
long p = 1L * a * b;
return p / gcd(a, b);
}
static long gcd(long a, long b) {
while (b != 0) {
long t = b;
b = a % b;
a = t;
}
return a;
}
static long gcd(long a, long b, long c) {
return gcd(a, gcd(b, c));
}
static class ArrayUtils {
static void swap(int[] a, int i, int j) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
static void swap(char[] a, int i, int j) {
char temp = a[i];
a[i] = a[j];
a[j] = temp;
}
static void print(char[] a) {
for (char c : a) {
out.print(c);
}
out.println("");
}
static int[] reverse(int[] data) {
int[] p = new int[data.length];
for (int i = 0, j = data.length - 1; i < data.length; i++, j--) {
p[i] = data[j];
}
return p;
}
static void prefixSum(long[] data) {
for (int i = 1; i < data.length; i++) {
data[i] += data[i - 1];
}
}
static void prefixSum(int[] data) {
for (int i = 1; i < data.length; i++) {
data[i] += data[i - 1];
}
}
static void suffixSum(int[] data) {
for (int i = data.length - 2; i >= 0; i--) {
data[i] += data[i + 1];
}
}
static long[] reverse(long[] data) {
long[] p = new long[data.length];
for (int i = 0, j = data.length - 1; i < data.length; i++, j--) {
p[i] = data[j];
}
return p;
}
static char[] reverse(char[] data) {
char[] p = new char[data.length];
for (int i = 0, j = data.length - 1; i < data.length; i++, j--) {
p[i] = data[j];
}
return p;
}
static int[] MergeSort(int[] A) {
if (A.length > 1) {
int q = A.length / 2;
int[] left = new int[q];
int[] right = new int[A.length - q];
System.arraycopy(A, 0, left, 0, q);
System.arraycopy(A, q, right, 0, A.length - q);
int[] left_sorted = MergeSort(left);
int[] right_sorted = MergeSort(right);
return Merge(left_sorted, right_sorted);
} else {
return A;
}
}
static int[] Merge(int[] left, int[] right) {
int[] A = new int[left.length + right.length];
int i = 0;
int j = 0;
for (int k = 0; k < A.length; k++) {
// To handle left becoming empty
if (i == left.length && j < right.length) {
A[k] = right[j];
j++;
continue;
}
// To handle right becoming empty
if (j == right.length && i < left.length) {
A[k] = left[i];
i++;
continue;
}
if (left[i] <= right[j]) {
A[k] = left[i];
i++;
} else {
A[k] = right[j];
j++;
}
}
return A;
}
static long[] MergeSort(long[] A) {
if (A.length > 1) {
int q = A.length / 2;
long[] left = new long[q];
long[] right = new long[A.length - q];
System.arraycopy(A, 0, left, 0, q);
System.arraycopy(A, q, right, 0, A.length - q);
long[] left_sorted = MergeSort(left);
long[] right_sorted = MergeSort(right);
return Merge(left_sorted, right_sorted);
} else {
return A;
}
}
static long[] Merge(long[] left, long[] right) {
long[] A = new long[left.length + right.length];
int i = 0;
int j = 0;
for (int k = 0; k < A.length; k++) {
// To handle left becoming empty
if (i == left.length && j < right.length) {
A[k] = right[j];
j++;
continue;
}
// To handle right becoming empty
if (j == right.length && i < left.length) {
A[k] = left[i];
i++;
continue;
}
if (left[i] <= right[j]) {
A[k] = left[i];
i++;
} else {
A[k] = right[j];
j++;
}
}
return A;
}
static int upper_bound(int[] data, int num, int start) {
int low = start;
int high = data.length - 1;
int mid = 0;
int ans = -1;
while (low <= high) {
mid = (low + high) / 2;
if (data[mid] < num) {
low = mid + 1;
} else if (data[mid] >= num) {
high = mid - 1;
ans = mid;
}
}
if (ans == -1) {
return 100000000;
}
return data[ans];
}
static int lower_bound(int[] data, int num, int start) {
int low = start;
int high = data.length - 1;
int mid = 0;
int ans = -1;
while (low <= high) {
mid = (low + high) / 2;
if (data[mid] <= num) {
low = mid + 1;
ans = mid;
} else if (data[mid] > num) {
high = mid - 1;
}
}
if (ans == -1) {
return 100000000;
}
return data[ans];
}
}
static boolean[] primeSieve(int n) {
boolean[] primes = new boolean[n + 1];
Arrays.fill(primes, true);
primes[0] = false;
primes[1] = false;
for (int i = 2; i <= Math.sqrt(n); i++) {
if (primes[i]) {
for (int j = i * i; j <= n; j += i) {
primes[j] = false;
}
}
}
return primes;
}
// Iterative Version
static HashMap<Integer, Boolean> subsets_sum_iter(int[] data) {
HashMap<Integer, Boolean> temp = new HashMap<Integer, Boolean>();
temp.put(data[0], true);
for (int i = 1; i < data.length; i++) {
HashMap<Integer, Boolean> t1 = new HashMap<Integer, Boolean>(temp);
t1.put(data[i], true);
for (int j : temp.keySet()) {
t1.put(j + data[i], true);
}
temp = t1;
}
return temp;
}
static HashMap<Integer, Integer> subsets_sum_count(int[] data) {
HashMap<Integer, Integer> temp = new HashMap<>();
temp.put(data[0], 1);
for (int i = 1; i < data.length; i++) {
HashMap<Integer, Integer> t1 = new HashMap<>(temp);
t1.merge(data[i], 1, ADD);
for (int j : temp.keySet()) {
t1.merge(j + data[i], temp.get(j) + 1, ADD);
}
temp = t1;
}
return temp;
}
static class Graph {
ArrayList<Integer>[] g;
boolean[] visited;
ArrayList<Integer>[] graph(int n) {
g = new ArrayList[n];
visited = new boolean[n];
for (int i = 0; i < n; i++) {
g[i] = new ArrayList<>();
}
return g;
}
void BFS(int s) {
Queue<Integer> Q = new ArrayDeque<>();
visited[s] = true;
Q.add(s);
while (!Q.isEmpty()) {
int v = Q.poll();
for (int a : g[v]) {
if (!visited[a]) {
visited[a] = true;
Q.add(a);
}
}
}
}
}
static class SparseTable {
int[] log;
int[][] st;
public SparseTable(int n, int k, int[] data, BiFunction<Integer, Integer, Integer> f) {
log = new int[n + 1];
st = new int[n][k + 1];
log[1] = 0;
for (int i = 2; i <= n; i++) {
log[i] = log[i / 2] + 1;
}
for (int i = 0; i < data.length; i++) {
st[i][0] = data[i];
}
for (int j = 1; j <= k; j++)
for (int i = 0; i + (1 << j) <= data.length; i++)
st[i][j] = f.apply(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
}
public int query(int L, int R, BiFunction<Integer, Integer, Integer> f) {
int j = log[R - L + 1];
return f.apply(st[L][j], st[R - (1 << j) + 1][j]);
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 2048);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public long nextLong() {
return Long.parseLong(next());
}
public int nextInt() {
return Integer.parseInt(next());
}
public int[] readAllInts(int n) {
int[] p = new int[n];
for (int i = 0; i < n; i++) {
p[i] = in.nextInt();
}
return p;
}
public int[] readAllInts(int n, int s) {
int[] p = new int[n + s];
for (int i = s; i < n + s; i++) {
p[i] = in.nextInt();
}
return p;
}
public long[] readAllLongs(int n) {
long[] p = new long[n];
for (int i = 0; i < n; i++) {
p[i] = in.nextLong();
}
return p;
}
public long[] readAllLongs(int n, int s) {
long[] p = new long[n + s];
for (int i = s; i < n + s; i++) {
p[i] = in.nextLong();
}
return p;
}
public double nextDouble() {
return Double.parseDouble(next());
}
}
static void exit(int a) {
out.close();
err.close();
System.exit(a);
}
static InputStream inputStream = System.in;
static OutputStream outputStream = System.out;
static OutputStream errStream = System.err;
static InputReader in = new InputReader(inputStream);
static PrintWriter out = new PrintWriter(outputStream);
static PrintWriter err = new PrintWriter(errStream);
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 844ed3de497c8d7659d469fbd8cf0050 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class Codeforces {
static int mod = (int) (1e9 + 7);
static void solve() {
long n = l();
long l = i();
long r = l();
long[] arr = new long[(int) (n+1)];
for (int i = 1; i <=n; i++) {
long next=(( l+i-1)/i)*i;
if(next>r){
System.out.println("NO");
return;
}
arr[i]=next;
}
System.out.println("YES");
for (int i = 1; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
}
public static void main(String[] args) {
int test = i();
while (test-- > 0) {
solve();
}
}
// ----->segmentTree--> segTree as class
// ----->lazy_Seg_tree --> lazy_Seg_tree as class
// -----> Trie --->Trie as class
// ----->fenwick_Tree ---> fenwick_Tree
// -----> POWER ---> long power(long x, long y) <----
// -----> LCM ---> long lcm(long x, long y) <----
// -----> GCD ---> long gcd(long x, long y) <----
// -----> SIEVE --> ArrayList<Integer> sieve(int N) <-----
// -----> NCR ---> long ncr(int n, int r) <----
// -----> BINARY_SEARCH ---> int binary_Search(long[]arr,long x) <----
// -----> (SORTING OF LONG, CHAR,INT) -->long[] sortLong(long[] a2)<--
// ----> DFS ---> void dfs(ArrayList<ArrayList<Integer>>edges,int child,int
// parent)<---
// ---> NODETOROOT --> ArrayList<Integer>
// node2Root(ArrayList<ArrayList<Integer>>edges,int child,int parent,int tofind)
// <--
// ---> LEVELS_TREE -->levels_Trees(ArrayList<HashSet<Integer>> edges, int
// child, int parent,int[]level,int currLevel) <--
// ---> K_THPARENT --> int k_thparent(int node,int[][]parent,int k) <---
// ---> TWOPOWERITHPARENTFILL --> void twoPowerIthParentFill(int[][]parent) <---
// -----> (INPUT OF INT,LONG ,STRING) -> int i() long l() String s()<-
// tempstart
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public int Int() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public String String() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public String next() {
return String();
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
static InputReader in = new InputReader(System.in);
public static int i() {
return in.Int();
}
public static long l() {
String s = in.String();
return Long.parseLong(s);
}
public static String s() {
return in.String();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 4f42d592711158648fdee84a7fcb6181 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.math.BigInteger;
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int testcase=sc.nextInt();
for(int tc=1;tc<=testcase;tc++){
//System.out.print("Case #"+tc+": ");
int n=sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
List<Integer> list = new ArrayList<>();
for(int i=1;i<=n;i++){
if((((l-1)/i)+1)*i <= r)
list.add((((l-1)/i)+1)*i);
else
break;
}
if(list.size() == n){
System.out.println("YES");
for(int i=0;i<n;i++)
System.out.print(list.get(i)+" ");
System.out.println();
}
else
System.out.println("NO");
}
sc.close();
}
static long gcd(long a, long b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
// method to return LCM of two numbers
// static int lcm(int a, int b)
// {
// return (a / gcd(a, b)) * b;
// }
static int f(int order[], int disAmount){
int count = 0;
for(int x : order){
if(x > 0 && disAmount % x == 0)
count++;
}
return count;
}
static int upper_bound(int arr[], int key)
{
int mid, N = arr.length;
// Initialise starting index and
// ending index
int low = 0;
int high = N;
// Till low is less than high
while (low < high && low != N) {
// Find the index of the middle element
mid = low + (high - low) / 2;
// If key is greater than or equal
// to arr[mid], then find in
// right subarray
if (key >= arr[mid]) {
low = mid + 1;
}
// If key is less than arr[mid]
// then find in left subarray
else {
high = mid;
}
}
// If key is greater than last element which is
// array[n-1] then upper bound
// does not exists in the array
if (low > N ) {
low--;
}
// Print the upper_bound index
return low;
}
static int lower_bound(int array[], int key)
{
// Initialize starting index and
// ending index
int low = 0, high = array.length;
int mid;
// Till high does not crosses low
while (low < high) {
// Find the index of the middle element
mid = low + (high - low) / 2;
// If key is less than or equal
// to array[mid], then find in
// left subarray
if (key <= array[mid]) {
high = mid;
}
// If key is greater than array[mid],
// then find in right subarray
else {
low = mid + 1;
}
}
// If key is greater than last element which is
// array[n-1] then lower bound
// does not exists in the array
if(low==-1)
low++;
// Returning the lower_bound index
return low;
}
static boolean palin(int arr[], int i, int j){
while(i < j){
if(arr[i] != arr[j])
return false;
i++;
j--;
}
return true;
}
static boolean palin(String s){
int i=0,j=s.length()-1;
while(i<j){
if(s.charAt(i)!=s.charAt(j))
return false;
i++;
j--;
}
return true;
}
static long minSum(int arr[], int n, int k)
{
// k must be smaller than n
if (n < k)
{
// System.out.println("Invalid");
return -1;
}
// Compute sum of first window of size k
long res = 0;
for (int i=0; i<k; i++)
res += arr[i];
// Compute sums of remaining windows by
// removing first element of previous
// window and adding last element of
// current window.
long curr_sum = res;
for (int i=k; i<n; i++)
{
curr_sum += arr[i] - arr[i-k];
res = Math.min(res, curr_sum);
}
return res;
}
static int nextIndex(int a[], int x){
int n=a.length;
for(int i=x;i<n-1;i++){
if(a[i]>a[i+1]){
return i;
}
}
return n;
}
static void rev(int a[], int i, int j){
while(i<j){
int t=a[i];
a[i]=a[j];
a[j]=t;
i++;
j--;
}
}
static int sorted(int arr[], int n)
{
// Array has one or no element or the
// rest are already checked and approved.
if (n == 1 || n == 0)
return 1;
// Unsorted pair found (Equal values allowed)
if (arr[n - 1] < arr[n - 2])
return 0;
// Last pair was sorted
// Keep on checking
return sorted(arr, n - 1);
}
static void sieveOfEratosthenes(int n, Set<Integer> set)
{
// Create a boolean array "prime[0..n]" and
// initialize all entries it as true. A value in
// prime[i] will finally be false if i is Not a
// prime, else true.
boolean prime[] = new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++) {
// If prime[p] is not changed, then it is a
// prime
if (prime[p] == true) {
// Update all multiples of p greater than or
// equal to the square of it numbers which
// are multiple of p and are less than p^2
// are already been marked.
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
for (int i = 2; i <= n; i++) {
if (prime[i] == true)
set.add(i);
}
}
static boolean isPowerOfTwo(int n)
{
return (int)(Math.ceil((Math.log(n) / Math.log(2))))
== (int)(Math.floor(((Math.log(n) / Math.log(2)))));
}
static int countBits(int number)
{
// log function in base 2
// take only integer part
return (int)(Math.log(number) /
Math.log(2) + 1);
}
public static void swap(int ans[], int i, int j) {
int temp=ans[i];
ans[i]=ans[j];
ans[j]=temp;
}
static int power(int x, int y, int p)
{
int res = 1; // Initialize result
x = x % p; // Update x if it is more than or
// equal to p
if (x == 0)
return 0; // In case x is divisible by p;
while (y > 0)
{
// If y is odd, multiply x with result
if ((y & 1) != 0)
res = (res * x) % p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 79d3b797291f328dbfa7c1fe34f687f6 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;
public class CF808B {
public static void main(String[] args) {
FastScanner sc=new FastScanner();
int T=sc.nextInt();
StringBuilder sb = new StringBuilder();
for (int tt=0; tt<T; tt++) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
ArrayList<Integer>ans = new ArrayList<>();
for(int i=1;i<=n;i++) {
if(l%i==0) {
ans.add(l);
}else {
int div = l/i;
int num = (div+1)*i;
if(num<=r) {
ans.add(num);
}else {
break;
}
}
}
if(ans.size()!=n) {
sb.append("NO").append('\n');
}else {
sb.append("YES").append('\n');
for(int x:ans) {
sb.append(x).append(" ");
}
sb.append('\n');
}
}
out.print(sb);
out.flush();
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 03b2d87c5a904db54af1f4c7fc0d3d8c | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes |
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;
public class CF808B {
public static void main(String[] args) {
FastScanner sc=new FastScanner();
int T=sc.nextInt();
StringBuilder sb = new StringBuilder();
for (int tt=0; tt<T; tt++) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
ArrayList<Integer>ans = new ArrayList<>();
for(int i=1;i<=n;i++) {
if(l%i==0) {
ans.add(l);
}else {
int div = l/i;
int num = (div+1)*i;
if(num<=r) {
ans.add(num);
}else {
break;
}
}
}
if(ans.size()!=n) {
sb.append("NO").append('\n');
}else {
sb.append("YES").append('\n');
for(int x:ans) {
sb.append(x).append(" ");
}
sb.append('\n');
}
}
out.print(sb);
out.flush();
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | ae9ea146a53cfe2fc48807b3f45272f2 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static long mod = 1000000007;
static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void main(String[] args) throws IOException {
FastReader sc = new FastReader();
int t = sc.nextInt();
while( t-- > 0) {
int n = sc.nextInt();
long l = sc.nextLong();
long r = sc.nextLong();
// if( r-l+1 >= n) {
long ans[] = new long[n];
boolean check = true;
for( int i = 1 ; i<= n; i++) {
long temp = r - (r%i);
// out.println( i +" " + temp);
if( temp < l) {
check = false;
}
else {
ans[i-1] = temp;
}
}
if( check) {
out.println("YES");
for( int i = 0 ; i< n ;i++) {
out.print(ans[i] + " ");
}
out.println();
}
else {
out.println("NO");
}
// }
// else {
// out.println("NO");
// }
}
out.flush();
}
/*
* look at test cases
* do significant case work
*/
public static boolean ifpowof2(long n ) {
return ((n&(n-1)) == 0);
}
static boolean isprime(long x ) {
if( x== 2) {
return true;
}
if( x%2 == 0) {
return false;
}
for( long i = 3 ;i*i <= x ;i+=2) {
if( x%i == 0) {
return false;
}
}
return true;
}
static boolean[] sieveOfEratosthenes(long n) {
boolean prime[] = new boolean[(int)n + 1];
for (int i = 0; i <= n; i++) {
prime[i] = true;
}
for (long p = 2; p * p <= n; p++) {
if (prime[(int)p] == true) {
for (long i = p * p; i <= n; i += p)
prime[(int)i] = false;
}
}
return prime;
}
public static int[] nextLargerElement(int[] arr, int n) {
Stack<Integer> stack = new Stack<>();
int rtrn[] = new int[n];
rtrn[n-1] = -1;
stack.push( n-1);
for( int i = n-2 ;i >= 0 ; i--){
int temp = arr[i];
int lol = -1;
while( !stack.isEmpty() && arr[stack.peek()] <= temp){
if(arr[stack.peek()] == temp ) {
lol = stack.peek();
}
stack.pop();
}
if( stack.isEmpty()){
if( lol != -1) {
rtrn[i] = lol;
}
else {
rtrn[i] = -1;
}
}
else{
rtrn[i] = stack.peek();
}
stack.push( i);
}
return rtrn;
}
static void mysort(int[] arr) {
for(int i=0;i<arr.length;i++) {
int rand = (int) (Math.random() * arr.length);
int loc = arr[rand];
arr[rand] = arr[i];
arr[i] = loc;
}
Arrays.sort(arr);
}
static void mySort(long[] arr) {
for(int i=0;i<arr.length;i++) {
int rand = (int) (Math.random() * arr.length);
long loc = arr[rand];
arr[rand] = arr[i];
arr[i] = loc;
}
Arrays.sort(arr);
}
static long gcd(long a, long b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
static long lcm(long a, long b)
{
return (a / gcd(a, b)) * b;
}
static long rightmostsetbit(long n) {
return n&-n;
}
static long leftmostsetbit(long n)
{
long k = (long)(Math.log(n) / Math.log(2));
return k;
}
static HashMap<Long,Long> primefactor( long n){
HashMap<Long ,Long> hm = new HashMap<>();
long temp = 0;
while( n%2 == 0) {
temp++;
n/=2;
}
if( temp!= 0) {
hm.put( 2L, temp);
}
long c = (long)Math.sqrt(n);
for( long i = 3 ; i <= c ; i+=2) {
temp = 0;
while( n% i == 0) {
temp++;
n/=i;
}
if( temp!= 0) {
hm.put( i, temp);
}
}
if( n!= 1) {
hm.put( n , 1L);
}
return hm;
}
static ArrayList<Long> allfactors(long abs) {
HashMap<Long,Integer> hm = new HashMap<>();
ArrayList<Long> rtrn = new ArrayList<>();
for( long i = 2 ;i*i <= abs; i++) {
if( abs% i == 0) {
hm.put( i , 0);
hm.put(abs/i, 0);
}
}
for( long x : hm.keySet()) {
rtrn.add(x);
}
if( abs != 0) {
rtrn.add(abs);
}
return rtrn;
}
public static int[][] prefixsum( int n , int m , int arr[][] ){
int prefixsum[][] = new int[n+1][m+1];
for( int i = 1 ;i <= n ;i++) {
for( int j = 1 ; j<= m ; j++) {
int toadd = 0;
if( arr[i-1][j-1] == 1) {
toadd = 1;
}
prefixsum[i][j] = toadd + prefixsum[i][j-1] + prefixsum[i-1][j] - prefixsum[i-1][j-1];
}
}
return prefixsum;
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 7ed6aa829c7467ff3a8d63c403587b68 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class B {
private static final long MOD = 1_000_000_007;
private static long binpow(long a, long b, long m) {
if(b == 0) {
return 1%m;
}
long res1 = binpow(a,b/2,m);
if(b%2 == 0) {
return res1 * res1 % m;
} else {
return a * res1 * res1 % m;
}
}
private static long mulInverseUnderModulo(long a, long m) {
return binpow(a, m-2, m);//Fermats little theorm
}
static class FastScanner {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while(!st.hasMoreTokens()) {
try {
st = new StringTokenizer(bf.readLine());
} catch(IOException e) { }
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
char nextChar() {
return next().charAt(0);
}
String nextLine() throws IOException{
return bf.readLine().trim();
}
}
static class Pair<T extends Comparable<T>, U extends Comparable<U>> implements Comparable<Pair<T,U>> {
T first;
U second;
Pair(){}
Pair(T first, U second) {
this.first = first;
this.second = second;
}
public String toString() {
return this.first + " " + this.second;
}
public int compareTo(Pair<T,U> rhs) {
int firstCompareResult = this.first.compareTo(rhs.first);
if(firstCompareResult == 0) {
return this.second.compareTo(rhs.second);
} else {
return firstCompareResult;
}
}
}
public static void main(String[] args) throws IOException {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
// int t = 1;
while(t-- > 0) {
int n = sc.nextInt();
long l = sc.nextLong(), r = sc.nextLong();
long[] ans = new long[n+1];
boolean flag = true;
for(int i=1;i<=n;i++) {
if(i>=l && i<=r) {
ans[i] = i;
}
else if(l >= i && l % i == 0) {
ans[i] = l;
}
else {
long potential = ((l/i) + 1 ) * i;
if(potential > r) {
flag = false;
break;
} else {
ans[i] = potential;
}
}
}
if(!flag) {
out.println("NO");
continue;
}
out.println("YES");
for(int i=1;i<=n;i++) out.print(ans[i] + " ");
out.println();
}
out.close();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 44b6f85a9061732d12c0b602746c24a6 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class DifferenceOfGCDs {
// For fast input output
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(new FileReader("input.txt"));
PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
} catch (Exception e) {
br = new BufferedReader(new InputStreamReader(System.in));
}
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
// end of fast i/o code
public static void main(String[] args) {
FastReader s = new FastReader();
int t = s.nextInt();
while (t-- > 0) {
int n = s.nextInt();
int l = s.nextInt();
int r = s.nextInt();
boolean flag = true;
int[] ans = new int[n];
for (int i = 1; i <= n; i++) {
int val = (l - 1) / i + 1;
val = val * i;
// System.out.println(val);
if (val >= l && val <= r) {
ans[i - 1] = val;
continue;
}
flag = false;
break;
}
if (flag) {
System.out.println("YES");
for (int i : ans) {
System.out.print(i + " ");
}
} else {
System.out.print("NO");
}
System.out.println();
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 7955cff130dfe614908dbdc60777a1fe | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.Math.PI;
import static java.lang.Math.min;
import static java.lang.System.arraycopy;
import static java.lang.System.exit;
import static java.util.Arrays.copyOf;
import java.util.LinkedList;
import java.util.List;
import java.util.Iterator;
import java.io.FileReader;
import java.io.FileWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Deque;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.Comparator;
import java.lang.StringBuilder;
import java.util.Collections;
import java.util.*;
import java.text.DecimalFormat;
public class Solution {
// static class Edge{
// int u, v, w;
// Edge(int u, int v, int w){
// this.u = u;
// this.v = v;
// this.w = w;
// }
// }
static class Pair{
int first, second;
Pair(int first, int second){
this.first = first;
this.second = second;
}
@Override
public String toString(){
return (this.first+" "+this.second);
}
}
// static class Tuple{
// int first, second, third;
// Tuple(int first, int second, int third){
// this.first = first;
// this.second =second;
// this.third = third;
// }
// @Override
// public String toString(){
// return first+" "+second+" "+third;
// }
// }
// static class Point{
// int x, y;
// Point(int x, int y){
// this.x = x;
// this.y = y;
// }
// @Override
// public String toString(){
// return x+" "+y;
// }
// }
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tok;
static int dx[] = {0, -1, 0, 1}; //left up right down
static int dy[] = {-1, 0, 1, 0};
static int MOD = (int)1e9+7, INF = (int)1e9;
static boolean vis[];
static ArrayList<Integer> adj[];
private static void solve() throws IOException{
int n = scanInt();
int arr[] = new int[n];
int l = scanInt(), r = scanInt();
for(int i = 1; i<=n; ++i){
if((((l-1)/i)+1)*i <= r){
arr[i-1] = (((l-1)/i)+1)*i;
}
else{
out.println("NO");
return;
}
}
out.println("YES");
for(int i = 0; i<n; ++i){
out.print(arr[i]+" ");
}
out.println();
}
private static int[] inputArray(int n) throws IOException {
int arr[] = new int[n];
for(int i=0; i<n; ++i)
arr[i] = scanInt();
return arr;
}
private static void displayArray(int arr[]){
for(int i = 0; i<arr.length; ++i)
out.print(arr[i]+" ");
out.println();
}
public static void main(String[] args) {
try {
long startTime = System.currentTimeMillis();
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
//in = new BufferedReader(new FileReader("input.txt"));
//out = new PrintWriter(new FileWriter("output.txt"));
int test = scanInt();
for(int t=1; t<=test; t++){
// out.print("Case #"+t+": ");
solve();
}
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
//out.println(totalTime+"---------- "+System.currentTimeMillis() );
in.close();
out.close();
} catch (Throwable e) {
e.printStackTrace();
exit(1);
}
}
static int scanInt() throws IOException {
return parseInt(scanString());
}
static long scanLong() throws IOException {
return parseLong(scanString());
}
static double scanDouble() throws IOException {
return parseDouble(scanString());
}
static String scanString() throws IOException {
if (tok == null || !tok.hasMoreTokens()) {
tok = new StringTokenizer(in.readLine());
}
return tok.nextToken();
}
static String scanLine() throws IOException {
return in.readLine();
}
private static void sort(int arr[]){
mergeSort(arr, 0, arr.length-1);
}
private static void sort(int arr[], int start, int end){
mergeSort(arr, start, end-1);
}
private static void mergeSort(int arr[], int start, int end){
if(start >= end)
return;
int mid = (start+end)/2;
mergeSort(arr, start, mid);
mergeSort(arr, mid+1, end);
merge(arr, start, mid, end);
}
private static void merge(int arr[], int start, int mid, int end){
int n1 = mid - start+1;
int n2 = end - mid;
int left[] = new int[n1];
int right[] = new int[n2];
for(int i = 0; i<n1; ++i){
left[i] = arr[i+start];
}
for(int i = 0; i<n2; ++i){
right[i] = arr[mid+1+i];
}
int i = 0, j = 0, curr = start;
while(i <n1 && j <n2){
if(left[i] <= right[j]){
arr[curr] = left[i];
++i;
}
else{
arr[curr] = right[j];
++j;
}
++curr;
}
while(i<n1){
arr[curr] = left[i];
++i; ++curr;
}
while(j<n2){
arr[curr] = right[j];
++j; ++curr;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 334eb7f7f882d1ad92e921e9d48ffdef | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
// write your code here
r.init(System.in);
int t = r.nextInt();
while (t-- > 0) {
int n = r.nextInt();
int L = r.nextInt();
int R = r.nextInt();
//String res = "";
boolean ans = true;
int[] arr = new int[n];
for (int i = 1; i <= n; i++) {
if (((L - 1) / i + 1) * i <= R) {
arr[i - 1] = ((L - 1) / i + 1) * i;
} else {
ans = false;
break;
}
}
if (ans) {
System.out.println("YES");
for (int i = 0; i < arr.length; i++) System.out.print(arr[i] + " ");
}
else System.out.println("NO");
}
}
}
class r {
static BufferedReader reader;
static StringTokenizer tokenizer;
static void init(InputStream input) {
reader = new BufferedReader(new InputStreamReader(input));
tokenizer
= new StringTokenizer("");
}
static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
//TODO add check for eof if necessary
tokenizer = new StringTokenizer(
reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static long nextLong() throws IOException {
return Long.parseLong(next());
}
static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | c213bbfa4d52db4f1fcd7d1920273af5 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class new1{
static int mod = 998244353;
public static long gcd(long a, long b)
{
if (a == 0)
return b;
return gcd(b%a, a);
}
public static void main(String[] args) throws IOException{
BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
FastReader s = new FastReader();
int t = s.nextInt();
for(int z = 1; z <= t; z++) {
int n = s.nextInt();
int l = s.nextInt();
int r = s.nextInt();
int[] ans = new int[n];
boolean pos = true;
for(int i = 1; i <= n; i++) {
int val = l + (i - l % i) % i;
if(val > r) pos = false;
ans[i - 1] = val;
}
if(!pos) output.write("NO" + "\n");
else {
output.write("YES" + "\n");
for(int i = 0; i < n; i++) {
output.write(ans[i] + " ");
}
output.write("\n");
}
}
output.flush();
}
}
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 99054d2b55116d815293cd335d339bd3 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
// whole solution
public class new1{
static int mod = 998244353;
public static long gcd(long a, long b)
{
if (a == 0)
return b;
return gcd(b%a, a);
}
public static void main(String[] args) throws IOException{
BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
FastReader s = new FastReader();
int t = s.nextInt();
for(int z = 1; z <= t; z++) {
int n = s.nextInt();
int l = s.nextInt();
int r = s.nextInt();
int[] ans = new int[n];
boolean pos = true;
for(int i = 1; i <= n; i++) {
int val = l + (i - l % i) % i;
if(val > r) pos = false;
ans[i - 1] = val;
}
if(!pos) output.write("NO" + "\n");
else {
output.write("YES" + "\n");
for(int i = 0; i < n; i++) {
output.write(ans[i] + " ");
}
output.write("\n");
}
}
output.flush();
}
}
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 67592693a5d1fb51ebea495def6d59df | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Codeforces {
public static class fastReader {
BufferedReader br;
StringTokenizer st;
public fastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static fastReader sc = new fastReader();
public static void main(String[] args) {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
StringBuilder ans = new StringBuilder();
boolean possible = true;
for (int i = 1; i <= n; i++) {
if(((l-1)/i+1)*i<=r){
ans.append((((l-1)/i+1)*i)+" ");
}else{
possible = false;
break;
}
}
if(possible){
System.out.println("YES");
System.out.println(ans.toString());
}else{
System.out.println("NO");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 5328c30f45950a5ff243f0452a13122b | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class TimePass {
public static int[] solve(int n,int l,int r) {
int out[]=new int[n];
out[0]=l;
for(int i=2;i<=n;i++) {
if(l%i==0) out[i-1]=l;
else {
int j=l/i;
int t=(j+1)*i;
if(t>r) return new int[] {-1};
out[i-1]=t;
}
}
return out;
}
public static void main (String[] args) throws java.lang.Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter out=new PrintWriter(System.out);
int testCases=Integer.parseInt(br.readLine());
while(testCases-->0){
String input[]=br.readLine().split(" ");
int n=Integer.parseInt(input[0]);
int l=Integer.parseInt(input[1]);
int r=Integer.parseInt(input[2]);
int ans[]=solve(n,l,r);
if(ans[0]==-1) {
out.print("NO");
}else {
out.print("YES");
out.print('\n');
for(int i=0;i<n;i++) {
out.print(ans[i]+" ");
}
}
out.print('\n');
}
out.close();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 5cf5fad97338e27764bf7b3a83d16138 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.Scanner;
public final class codeforces1708B {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args){
int t=sc.nextInt();
for(int i=0; i<t; i++){
eachCase();
}
}
static void eachCase(){
int n=sc.nextInt();
long l=sc.nextLong(), r=sc.nextLong();
long[] a=new long[n];
for(int i=0; i<n; i++){
a[i]=l%(i+1)==0?l:l+(i+1)-(l%(i+1));
if(!(a[i]>=l && a[i]<=r)){
System.out.println("NO");
return;
}
}
System.out.println("YES");
for(int i=0; i<n; i++){
System.out.print(a[i]+" ");
}
System.out.println("");
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | d028be8f2edf0ed70bd782c60730fe25 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution
{
private static class FastIO {
private static class FastReader
{
BufferedReader br;
StringTokenizer st;
FastReader()
{
br = new BufferedReader(new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble() { return Double.parseDouble(next()); }
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
private static PrintWriter out = new PrintWriter(System.out);
private static FastReader in = new FastReader();
public void print(String s) {out.print(s);}
public void println(String s) {out.println(s);}
public void println() {
println("");
}
public void print(int i) {out.print(i);}
public void print(long i) {out.print(i);}
public void print(char i) {out.print(i);}
public void print(double i) {out.print(i);}
public void println(int i) {out.println(i);}
public void println(long i) {out.println(i);}
public void println(char i) {out.println(i);}
public void println(double i) {out.println(i);}
public void printIntArrayWithoutSpaces(int[] a) {
for(int i : a) {
out.print(i);
}
out.println();
}
public void printIntArrayWithSpaces(int[] a) {
for(int i : a) {
out.print(i + " ");
}
out.println();
}
public void printIntArrayNewLine(int[] a) {
for(int i : a) {
out.println(i);
}
}
public int[] getIntArray(int n) {
int[] res = new int[n];
for(int i = 0; i < n; i++) {
res[i] = in.nextInt();
}
return res;
}
public List<Integer> getIntList(int n) {
List<Integer> list = new ArrayList<>();
for(int i = 0; i < n; i++) {
list.add(in.nextInt());
}
return list;
}
public static void printKickstartCase(int i) {
out.print("Case #" + i + ": ");
}
public String next() {return in.next();}
int nextInt() { return in.nextInt(); }
char nextChar() {return in.next().charAt(0);}
long nextLong() { return in.nextLong(); }
double nextDouble() { return in.nextDouble(); }
String nextLine() {return in.nextLine();}
public void close() {
out.flush();
out.close();
}
}
private static final FastIO io = new FastIO();
private static class MathUtil {
public static final int MOD = 1000000007;
public static int gcd(int a, int b) {
if(b == 0) {
return a;
}
return gcd(b, a % b);
}
public static int gcd(int[] a) {
if(a.length == 0) {
return 0;
}
int res = a[0];
for(int i = 1; i < a.length; i++) {
res = gcd(res, a[i]);
}
return res;
}
public static int gcd(List<Integer> a) {
if(a.size() == 0) {
return 0;
}
int res = a.get(0);
for(int i = 1; i < a.size(); i++) {
res = gcd(res, a.get(i));
}
return res;
}
public static int modular_mult(int a, int b, int M) {
long res = (long)a * b;
return (int)(res % M);
}
public static int modular_mult(int a, int b) {
return modular_mult(a, b, MOD);
}
public static int modular_add(int a, int b, int M) {
long res = (long)a + b;
return (int)(res % M);
}
public static int modular_add(int a, int b) {
return modular_add(a, b, MOD);
}
public static int modular_sub(int a, int b, int M) {
long res = ((long)a - b) + M;
return (int)(res % M);
}
public static int modular_sub(int a, int b) {
return modular_sub(a, b, MOD);
}
//public static int modular_div(int a, int b, int M) {}
//public static int modular_div(int a, int b) {return modular_div(a, b, MOD);}
public static int pow(int a, int b, int M) {
int res = 1;
while (b > 0) {
if ((b & 1) == 1) {
res = modular_mult(res, a, M);
}
a = modular_mult(a, a, M);
b = b >> 1;
}
return res;
}
public static int pow(int a, int b) {
return pow(a, b, MOD);
}
/*public static int fact(int i, int M) {
}
public static int fact(int i) {
}
public static void preComputeFact(int i) {
}
public static int mod_mult_inverse(int den, int mod) {
}
public static void C(int n, int r) {
}*/
}
private static class ArrayUtil {
@FunctionalInterface
private static interface NumberPairComparator {
boolean test(int a, int b);
}
public static int[] nextGreaterOrSmallerRight(int[] a, NumberPairComparator npc) {
int n = a.length;
int[] res = new int[n];
Stack<Integer> stack = new Stack<>();
for(int i = 0; i < n; i++) {
int cur = a[i];
while(!stack.isEmpty() && npc.test(a[stack.peek()], cur)) {
res[stack.pop()] = i;
}
stack.push(i);
}
while(!stack.isEmpty()) {
res[stack.pop()] = n;
}
return res;
}
public static int[] nextGreaterOrSmallerLeft(int[] a, NumberPairComparator npc) {
int n = a.length;
int[] res = new int[n];
Stack<Integer> stack = new Stack<>();
for(int i = n - 1; i >= 0; i--) {
int cur = a[i];
while(!stack.isEmpty() && npc.test(a[stack.peek()], cur)) {
res[stack.pop()] = i;
}
stack.push(i);
}
while(!stack.isEmpty()) {
res[stack.pop()] = n;
}
return res;
}
public static Map<Integer, Integer> getFreqMap(int[] a) {
Map<Integer, Integer> map = new HashMap<>();
for(int i : a) {
map.put(i, map.getOrDefault(i, 0) + 1);
}
return map;
}
public static long arraySum(int[] a) {
long sum = 0;
for(int i : a) {
sum += i;
}
return sum;
}
private static int maxIndex(int[] a) {
int max = Integer.MIN_VALUE;
int max_index = -1;
for(int i = 0; i < a.length; i++) {
if(a[i] > max) {
max = a[i];
max_index = i;
}
}
return max_index;
}
}
private static final int M = 1000000007;
private static final String yes = "YES";
private static final String no = "NO";
private static int MAX = M / 100;
private static final int MIN = -MAX;
private static final int UNVISITED = -1;
private static class Pair {
int x;
int y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return "x: " + x + " y: " + y;
}
}
private static final long e3 = 1_000;
private static final long e6 = 1_000_000;
private static final long e9 = 1_000_000_000;
private static final long e12 = e9 * e3;
private static final long e15 = e9 * e6;
private static final long e18 = e9 * e9;
public static void main(String[] args)
{
int testcases = io.nextInt();
// int testcases = 1;
for(int zqt = 0; zqt < testcases; zqt ++) {
int n = io.nextInt();
int l = io.nextInt();
int r = io.nextInt();
int[] res = new int[n];
boolean possible = true;
for(int i = 0; i < n; i ++) {
long num = l % (i + 1) == 0 ? l : (long) ((l / (i + 1)) + 1) * (i + 1);
if(num > r) {
possible = false;
break;
}
res[i] = (int)num;
}
if (!possible) {
io.println(no);
}
else {
io.println(yes);
for(int v : res) {
io.print(v + " ");
}
io.println();
}
}
io.close();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 9c5bbdac246c7233a3d0f58283a1622a | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
int binary(int arr[], int x)
{
int l = 0, r = arr.length - 1;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x)
return m;
if (arr[m] < x)
l = m + 1;
else
r = m - 1;
}
return -1;
}
public static void main (String[] args) throws java.lang.Exception
{
OutputStream outputStream =System.out;
PrintWriter out =new PrintWriter(outputStream);
FastReader sc =new FastReader();
int t = sc.nextInt();
while(t-->0)
{
int n =sc.nextInt(),l=sc.nextInt(),r =sc.nextInt(),i=1;
int[] a = new int[n+1];
Arrays.fill(a,-1);
boolean c=true;
while(i<=n&&c){
int m = l%i;
if(m==0) a[i]=l;
else if(l+i-m<=r) a[i]=l+i-m;
if(a[i]==-1) c=false;
i++;
}
if(!c){
out.print("NO\n"); continue;
}
out.print("YES\n");
for(int j =1;j<=n;j++) out.print(a[j]+" ");
out.print("\n");
}
out.close();
// your code goes here
}
}
class pair
{
long r;
long d;
public pair(long r , long d)
{
this.r= r;
this.d= d;
}
}
class solution{
public solution(){
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | feb6dce59dc151799d1ede4801341657 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | //package Practise_problems;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;
public class DifferenceGCD {
public static void main(String []args) {
FastScanner fs=new FastScanner();
int t=fs.nextInt();
while(t-->0) {
int n=fs.nextInt();
int l=fs.nextInt();
int r=fs.nextInt();
boolean flag=true;
List<Integer> list=new ArrayList<>();
for(int i=1;i<=n;i++) {
int val=((l-1)/i+1)*i;
list.add(val);
if(val>=l&&val<=r)
continue;
flag=false;
break;
}
if(flag) {
System.out.println("YES");
for(int val:list)
System.out.print(val+" ");
System.out.println();
}
else
System.out.println("NO");
}
}
static final Random random=new Random();
static void ruffleSort(int[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 1d9dba54087ee0a8d95f19851ecbbc75 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
/*
* 11223456
*
*
*/
public class Codeforces {
public static void main(String[] args) {
FastReader fastReader = new FastReader();
PrintWriter out = new PrintWriter(System.out);
int t = fastReader.nextInt();
while (t-- > 0) {
long n = fastReader.nextLong();
long l = fastReader.nextLong();
long r = fastReader.nextLong();
boolean isValid = true;
StringBuilder ans = new StringBuilder();
for (long i = 1; i <= n; i++) {
if (l % i == 0) {
ans.append(l).append(" ");
continue;
}
if (l > i) {
long add = (l / i) + 1;
add = (add * i) - l;
if (l + add > r) {
isValid = false;
break;
} else {
ans.append(l + add).append(" ");
}
} else {
long diff = i - l;
if (l + diff > r) {
isValid = false;
break;
} else {
ans.append(l + diff).append(" ");
}
}
}
if (isValid) {
out.println("YES");
out.println(ans);
} else {
out.println("NO");
}
}
out.close();
}
// constants
static final int IBIG = 1000000007;
static final int IMAX = 2147483647;
static final long LMAX = 9223372036854775807L;
static Random __r = new Random();
// math util
static int minof(int a, int b, int c) {
return min(a, min(b, c));
}
static int minof(int... x) {
if (x.length == 1)
return x[0];
if (x.length == 2)
return min(x[0], x[1]);
if (x.length == 3)
return min(x[0], min(x[1], x[2]));
int min = x[0];
for (int i = 1; i < x.length; ++i)
if (x[i] < min)
min = x[i];
return min;
}
static long minof(long a, long b, long c) {
return min(a, min(b, c));
}
static long minof(long... x) {
if (x.length == 1)
return x[0];
if (x.length == 2)
return min(x[0], x[1]);
if (x.length == 3)
return min(x[0], min(x[1], x[2]));
long min = x[0];
for (int i = 1; i < x.length; ++i)
if (x[i] < min)
min = x[i];
return min;
}
static int maxof(int a, int b, int c) {
return max(a, max(b, c));
}
static int maxof(int... x) {
if (x.length == 1)
return x[0];
if (x.length == 2)
return max(x[0], x[1]);
if (x.length == 3)
return max(x[0], max(x[1], x[2]));
int max = x[0];
for (int i = 1; i < x.length; ++i)
if (x[i] > max)
max = x[i];
return max;
}
static long maxof(long a, long b, long c) {
return max(a, max(b, c));
}
static long maxof(long... x) {
if (x.length == 1)
return x[0];
if (x.length == 2)
return max(x[0], x[1]);
if (x.length == 3)
return max(x[0], max(x[1], x[2]));
long max = x[0];
for (int i = 1; i < x.length; ++i)
if (x[i] > max)
max = x[i];
return max;
}
static int powi(int a, int b) {
if (a == 0)
return 0;
int ans = 1;
while (b > 0) {
if ((b & 1) > 0)
ans *= a;
a *= a;
b >>= 1;
}
return ans;
}
static long powl(long a, int b) {
if (a == 0)
return 0;
long ans = 1;
while (b > 0) {
if ((b & 1) > 0)
ans *= a;
a *= a;
b >>= 1;
}
return ans;
}
static int fli(double d) {
return (int) d;
}
static int cei(double d) {
return (int) ceil(d);
}
static long fll(double d) {
return (long) d;
}
static long cel(double d) {
return (long) ceil(d);
}
static int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
static int lcm(int a, int b) {
return (a / gcd(a, b)) * b;
}
static long gcd(long a, long b) {
return b == 0 ? a : gcd(b, a % b);
}
static long lcm(long a, long b) {
return (a / gcd(a, b)) * b;
}
static int[] exgcd(int a, int b) {
if (b == 0)
return new int[] { 1, 0 };
int[] y = exgcd(b, a % b);
return new int[] { y[1], y[0] - y[1] * (a / b) };
}
static long[] exgcd(long a, long b) {
if (b == 0)
return new long[] { 1, 0 };
long[] y = exgcd(b, a % b);
return new long[] { y[1], y[0] - y[1] * (a / b) };
}
static int randInt(int min, int max) {
return __r.nextInt(max - min + 1) + min;
}
static long mix(long x) {
x += 0x9e3779b97f4a7c15L;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L;
x = (x ^ (x >> 27)) * 0x94d049bb133111ebL;
return x ^ (x >> 31);
}
public static boolean[] findPrimes(int limit) {
assert limit >= 2;
final boolean[] nonPrimes = new boolean[limit];
nonPrimes[0] = true;
nonPrimes[1] = true;
int sqrt = (int) Math.sqrt(limit);
for (int i = 2; i <= sqrt; i++) {
if (nonPrimes[i])
continue;
for (int j = i; j < limit; j += i) {
if (!nonPrimes[j] && i != j)
nonPrimes[j] = true;
}
}
return nonPrimes;
}
// array util
static void reverse(int[] a) {
for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
int swap = a[i];
a[i] = a[n - i - 1];
a[n - i - 1] = swap;
}
}
static void reverse(long[] a) {
for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
long swap = a[i];
a[i] = a[n - i - 1];
a[n - i - 1] = swap;
}
}
static void reverse(double[] a) {
for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
double swap = a[i];
a[i] = a[n - i - 1];
a[n - i - 1] = swap;
}
}
static void reverse(char[] a) {
for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
char swap = a[i];
a[i] = a[n - i - 1];
a[n - i - 1] = swap;
}
}
static void shuffle(int[] a) {
int n = a.length - 1;
for (int i = 0; i < n; ++i) {
int ind = randInt(i, n);
int swap = a[i];
a[i] = a[ind];
a[ind] = swap;
}
}
static void shuffle(long[] a) {
int n = a.length - 1;
for (int i = 0; i < n; ++i) {
int ind = randInt(i, n);
long swap = a[i];
a[i] = a[ind];
a[ind] = swap;
}
}
static void shuffle(double[] a) {
int n = a.length - 1;
for (int i = 0; i < n; ++i) {
int ind = randInt(i, n);
double swap = a[i];
a[i] = a[ind];
a[ind] = swap;
}
}
static void rsort(int[] a) {
shuffle(a);
sort(a);
}
static void rsort(long[] a) {
shuffle(a);
sort(a);
}
static void rsort(double[] a) {
shuffle(a);
sort(a);
}
static int[] copy(int[] a) {
int[] ans = new int[a.length];
for (int i = 0; i < a.length; ++i)
ans[i] = a[i];
return ans;
}
static long[] copy(long[] a) {
long[] ans = new long[a.length];
for (int i = 0; i < a.length; ++i)
ans[i] = a[i];
return ans;
}
static double[] copy(double[] a) {
double[] ans = new double[a.length];
for (int i = 0; i < a.length; ++i)
ans[i] = a[i];
return ans;
}
static char[] copy(char[] a) {
char[] ans = new char[a.length];
for (int i = 0; i < a.length; ++i)
ans[i] = a[i];
return ans;
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] ria(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = Integer.parseInt(next());
return a;
}
long nextLong() {
return Long.parseLong(next());
}
long[] rla(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = Long.parseLong(next());
return a;
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 8483173dd71bb9621e09e549c61427bb | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class Solution {
static class RealScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
public static void main(String[] args) {
RealScanner sc = new RealScanner();
int t = sc.nextInt();
while (t-- > 0) {
int n, l, r;
n = sc.nextInt();
l = sc.nextInt();
r = sc.nextInt();
List<Integer> list = new ArrayList<>();
for (int i = 1; i <= n; i++) {
list.add(((l + i - 1) / i) * i);
}
// System.out.println(list);
boolean check = true;
for (int i = 0; i < n; i++) {
if (list.get(i) > r) {
check = false;
break;
}
}
if (check) {
System.out.println("YES");
for (int i : list) {
System.out.print(i + " ");
}
System.out.println();
} else {
System.out.println("NO");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 8e4680c38179131988b28c6ce74ba091 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes |
import java.util.*;
import java.io.*;
import java.math.*;
public class D {
static boolean check(int i, int j, int n, int m,int arr[][]) {
if(i<0 || i>=n || j<0 || j>=m)
return false;
if(arr[i][j]!=1)
return false;
return true;
}
static long gcd(long a, long b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
static boolean isPalindrome(String str)
{
int i = 0, j = str.length() - 1;
while (i < j) {
if (str.charAt(i) != str.charAt(j))
return false;
i++;
j--;
}
return true;
}
static void solve()
{
Scanner sc = new Scanner(System.in);
sc.close();
}
static int bsearch(int arr[], int l, int h, int key)
{
return -1;
}
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
//StringBuilder ans= new StringBuilder("");
for(int k=1;k<=t;k++)
{
int n=sc.nextInt();
int l=sc.nextInt();
int r=sc.nextInt();
int ans[]= new int[n];
int z=0;
for(int i=0;i<n;i++)
{
int temp=(i+l)/(i+1);
if(temp*(i+1)>r)
{
z=1;break;
}
ans[i]=temp*(i+1);
}
if(z==0)
{
System.out.println("YES");
for(int i=0;i<n;i++)
{
System.out.print(ans[i]+" ");
}
System.out.println();
}
else
System.out.println("NO");
}
sc.close();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 3bbf4bb2cc5620c70984bcff27acbd61 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static ContestScanner sc = new ContestScanner(System.in);
static PrintWriter pw = new PrintWriter(System.out);
static StringBuilder sb = new StringBuilder();
static long mod = (long) 1e9 + 7;
public static void main(String[] args) throws Exception {
int T = sc.nextInt();
for(int i = 0; i < T; i++)solve();
//solve();
pw.flush();
}
public static void solve() {
int n = sc.nextInt();
long l = sc.nextInt();
long r = sc.nextInt();
long[] ans = new long[n];
long now = l;
for(int i = 1; i <= n; i++){
long minus = (now%i);
long plus = (i-(now%i))%i;
if(now-minus < l){
if(now+plus > r){
pw.println("NO");
return;
}else{
now += plus;
ans[i-1] = now;
}
}else{
now -= minus;
ans[i-1] = now;
}
}
for(long v : ans){
sb.append(v).append(" ");
}
pw.println("YES");
pw.println(sb.toString());
sb.setLength(0);
}
private static long gcd(long a, long b)
{
while (b > 0)
{
long temp = b;
b = a % b; // % is remainder
a = temp;
}
return a;
}
static class GeekInteger {
public static void save_sort(int[] array) {
shuffle(array);
Arrays.sort(array);
}
public static int[] shuffle(int[] array) {
int n = array.length;
Random random = new Random();
for (int i = 0, j; i < n; i++) {
j = i + random.nextInt(n - i);
int randomElement = array[j];
array[j] = array[i];
array[i] = randomElement;
}
return array;
}
public static void save_sort(long[] array) {
shuffle(array);
Arrays.sort(array);
}
public static long[] shuffle(long[] array) {
int n = array.length;
Random random = new Random();
for (int i = 0, j; i < n; i++) {
j = i + random.nextInt(n - i);
long randomElement = array[j];
array[j] = array[i];
array[i] = randomElement;
}
return array;
}
}
}
/**
* refercence : https://github.com/NASU41/AtCoderLibraryForJava/blob/master/ContestIO/ContestScanner.java
*/
class ContestScanner {
private final java.io.InputStream in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private static final long LONG_MAX_TENTHS = 922337203685477580L;
private static final int LONG_MAX_LAST_DIGIT = 7;
private static final int LONG_MIN_LAST_DIGIT = 8;
public ContestScanner(java.io.InputStream in){
this.in = in;
}
public ContestScanner(java.io.File file) throws java.io.FileNotFoundException {
this(new java.io.BufferedInputStream(new java.io.FileInputStream(file)));
}
public ContestScanner(){
this(System.in);
}
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
}else{
ptr = 0;
try {
buflen = in.read(buffer);
} catch (java.io.IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte()) return buffer[ptr++]; else return -1;
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
public boolean hasNext() {
while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
return hasNextByte();
}
public String next() {
if (!hasNext()) throw new java.util.NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new java.util.NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
int digit = b - '0';
if (n >= LONG_MAX_TENTHS) {
if (n == LONG_MAX_TENTHS) {
if (minus) {
if (digit <= LONG_MIN_LAST_DIGIT) {
n = -n * 10 - digit;
b = readByte();
if (!isPrintableChar(b)) {
return n;
} else if (b < '0' || '9' < b) {
throw new NumberFormatException(
String.format("%d%s... is not number", n, Character.toString(b))
);
}
}
} else {
if (digit <= LONG_MAX_LAST_DIGIT) {
n = n * 10 + digit;
b = readByte();
if (!isPrintableChar(b)) {
return n;
} else if (b < '0' || '9' < b) {
throw new NumberFormatException(
String.format("%d%s... is not number", n, Character.toString(b))
);
}
}
}
}
throw new ArithmeticException(
String.format("%s%d%d... overflows long.", minus ? "-" : "", n, digit)
);
}
n = n * 10 + digit;
}else if(b == -1 || !isPrintableChar(b)){
return minus ? -n : n;
}else{
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
return (int) nl;
}
public double nextDouble() {
return Double.parseDouble(next());
}
public long[] nextLongArray(int length){
long[] array = new long[length];
for(int i=0; i<length; i++) array[i] = this.nextLong();
return array;
}
public long[] nextLongArray(int length, java.util.function.LongUnaryOperator map){
long[] array = new long[length];
for(int i=0; i<length; i++) array[i] = map.applyAsLong(this.nextLong());
return array;
}
public int[] nextIntArray(int length){
int[] array = new int[length];
for(int i=0; i<length; i++) array[i] = this.nextInt();
return array;
}
public int[] nextIntArray(int length, java.util.function.IntUnaryOperator map){
int[] array = new int[length];
for(int i=0; i<length; i++) array[i] = map.applyAsInt(this.nextInt());
return array;
}
public double[] nextDoubleArray(int length){
double[] array = new double[length];
for(int i=0; i<length; i++) array[i] = this.nextDouble();
return array;
}
public double[] nextDoubleArray(int length, java.util.function.DoubleUnaryOperator map){
double[] array = new double[length];
for(int i=0; i<length; i++) array[i] = map.applyAsDouble(this.nextDouble());
return array;
}
public long[][] nextLongMatrix(int height, int width){
long[][] mat = new long[height][width];
for(int h=0; h<height; h++) for(int w=0; w<width; w++){
mat[h][w] = this.nextLong();
}
return mat;
}
public int[][] nextIntMatrix(int height, int width){
int[][] mat = new int[height][width];
for(int h=0; h<height; h++) for(int w=0; w<width; w++){
mat[h][w] = this.nextInt();
}
return mat;
}
public double[][] nextDoubleMatrix(int height, int width){
double[][] mat = new double[height][width];
for(int h=0; h<height; h++) for(int w=0; w<width; w++){
mat[h][w] = this.nextDouble();
}
return mat;
}
public char[][] nextCharMatrix(int height, int width){
char[][] mat = new char[height][width];
for(int h=0; h<height; h++){
String s = this.next();
for(int w=0; w<width; w++){
mat[h][w] = s.charAt(w);
}
}
return mat;
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | e0fd7d25e1c5eaac79fd2f1590bd4d44 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.*;
import java.util.Scanner;
import java.util.StringTokenizer;
public class copy {
static int log=30;
static int[][] ancestor;
static int[] depth;
static void sieveOfEratosthenes(int n, ArrayList<Integer> arr) {
boolean prime[] = new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++) {
// If prime[p] is not changed, then it is a
// prime
if (prime[p]) {
// Update all multiples of p
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
for (int i = 2; i <= n; i++) {
if (prime[i]) {
arr.add(i);
}
}
}
public static long fac(long N, long mod) {
if (N == 0)
return 1;
if(N==1)
return 1;
return ((N % mod) * (fac(N - 1, mod) % mod)) % mod;
}
static long power(long x, long y, long p) {
// Initialize result
long res = 1;
// Update x if it is more than or
// equal to p
x = x % p;
while (y > 0) {
// If y is odd, multiply x
// with result
if (y % 2 == 1)
res = (res * x) % p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
// Returns n^(-1) mod p
static long modInverse(long n, long p) {
return power(n, p - 2, p);
}
// Returns nCr % p using Fermat's
// little theorem.
static long nCrModPFermat(long n, long r,
long p) {
if (n < r)
return 0;
// Base case
if (r == 0)
return 1;
return ((fac(n, p) % p * (modInverse(fac(r, p), p)
% p)) % p * (modInverse(fac(n - r, p), p)
% p)) % p;
}
public static int find(int[] parent, int x) {
if (parent[x] == x)
return x;
return find(parent, parent[x]);
}
public static void merge(int[] parent, int[] rank, int x, int y,int[] child) {
int x1 = find(parent, x);
int y1 = find(parent, y);
if (rank[x1] > rank[y1]) {
parent[y1] = x1;
child[x1]+=child[y1];
} else if (rank[y1] > rank[x1]) {
parent[x1] = y1;
child[y1]+=child[x1];
} else {
parent[y1] = x1;
child[x1]+=child[y1];
rank[x1]++;
}
}
public static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
static int power(int x, int y, int p)
{
int res = 1;
x = x % p;
while (y > 0) {
if (y % 2 == 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
// Returns n^(-1) mod p
static int modInverse(int n, int p)
{
return power(n, p - 2, p);
}
// Returns nCr % p using Fermat's
// little theorem.
static int nCrModPFermat(int n, int r,
int p)
{
if (n<r)
return 0;
// Base case
if (r == 0)
return 1;
// Fill factorial array so that we
// can find all factorial of r, n
// and n-r
int[] fac = new int[n + 1];
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[n] * modInverse(fac[r], p)
% p * modInverse(fac[n - r], p)
% p)
% p;
}
public static long[][] ncr(int n,int r)
{
long[][] dp=new long[n+1][r+1];
for(int i=0;i<=n;i++)
dp[i][0]=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=r;j++)
{
if(j>i)
continue;
dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
}
}
return dp;
}
public static boolean prime(long N)
{
int c=0;
for(int i=2;i*i<=N;i++)
{
if(N%i==0)
++c;
}
return c==0;
}
public static int sparse_ancestor_table(ArrayList<ArrayList<Integer>> arr,int x,int parent,int[] child)
{
int c=0;
for(int i:arr.get(x))
{
if(i!=parent)
{
// System.out.println(i+" hello "+x);
depth[i]=depth[x]+1;
ancestor[i][0]=x;
// if(i==2)
// System.out.println(parent+" hello");
for(int j=1;j<log;j++)
ancestor[i][j]=ancestor[ancestor[i][j-1]][j-1];
c+=sparse_ancestor_table(arr,i,x,child);
}
}
child[x]=1+c;
return child[x];
}
public static int lca(int x,int y)
{
if(depth[x]<depth[y])
{
int temp=x;
x=y;
y=temp;
}
x=get_kth_ancestor(depth[x]-depth[y],x);
if(x==y)
return x;
// System.out.println(x+" "+y);
for(int i=log-1;i>=0;i--)
{
if(ancestor[x][i]!=ancestor[y][i])
{
x=ancestor[x][i];
y=ancestor[y][i];
}
}
return ancestor[x][0];
}
public static int get_kth_ancestor(int K,int x)
{
if(K==0)
return x;
int node=x;
for(int i=0;i<log;i++)
{
if(K%2!=0)
{
node=ancestor[node][i];
}
K/=2;
}
return node;
}
public static ArrayList<Integer> primeFactors(int n)
{
// Print the number of 2s that divide n
ArrayList<Integer> factors=new ArrayList<>();
if(n%2==0)
factors.add(2);
while (n%2==0)
{
n /= 2;
}
// n must be odd at this point. So we can
// skip one element (Note i = i +2)
for (int i = 3; i <= Math.sqrt(n); i+= 2)
{
// While i divides n, print i and divide n
if(n%i==0)
factors.add(i);
while (n%i == 0)
{
n /= i;
}
}
// This condition is to handle the case when
// n is a prime number greater than 2
if (n > 2)
{
factors.add(n);
}
return factors;
}
static long ans=1,mod=1000000007;
public static void recur(long X,long N,int index,ArrayList<Integer> temp)
{
// System.out.println(X);
if(index==temp.size())
{
System.out.println(X);
ans=((ans%mod)*(X%mod))%mod;
return;
}
for(int i=0;i<=60;i++)
{
if(X*Math.pow(temp.get(index),i)<=N)
recur(X*(long)Math.pow(temp.get(index),i),N,index+1,temp);
else
break;
}
}
public static int upper(ArrayList<Integer> temp,int X)
{
int l=0,r=temp.size()-1;
while(l<=r)
{
int mid=(l+r)/2;
if(temp.get(mid)==X)
return mid;
// System.out.println(mid+" "+temp.get(mid));
if(temp.get(mid)<X)
l=mid+1;
else
{
if(mid-1>=0 && temp.get(mid-1)>=X)
r=mid-1;
else
return mid;
}
}
return -1;
}
public static int lower(ArrayList<Integer> temp,int X)
{
int l=0,r=temp.size()-1;
while(l<=r)
{
int mid=(l+r)/2;
if(temp.get(mid)==X)
return mid;
// System.out.println(mid+" "+temp.get(mid));
if(temp.get(mid)>X)
r=mid-1;
else
{
if(mid+1<temp.size() && temp.get(mid+1)<=X)
l=mid+1;
else
return mid;
}
}
return -1;
}
public static int[] check(String shelf,int[][] queries)
{
int[] arr=new int[queries.length];
ArrayList<Integer> indices=new ArrayList<>();
for(int i=0;i<shelf.length();i++)
{
char ch=shelf.charAt(i);
if(ch=='|')
indices.add(i);
}
for(int i=0;i<queries.length;i++)
{
int x=queries[i][0]-1;
int y=queries[i][1]-1;
int left=upper(indices,x);
int right=lower(indices,y);
if(left<=right && left!=-1 && right!=-1)
{
arr[i]=indices.get(right)-indices.get(left)+1-(right-left+1);
}
else
arr[i]=0;
}
return arr;
}
static boolean check;
public static void check(ArrayList<ArrayList<Integer>> arr,int x,int[] color,boolean[] visited)
{
visited[x]=true;
PriorityQueue<Integer> pq=new PriorityQueue<>();
for(int i:arr.get(x))
{
if(color[i]<color[x])
pq.add(color[i]);
if(color[i]==color[x])
check=false;
if(!visited[i])
check(arr,i,color,visited);
}
int start=1;
while(pq.size()>0)
{
int temp=pq.poll();
if(temp==start)
++start;
else
break;
}
if(start!=color[x])
check=false;
}
static boolean cycle;
public static void cycle(boolean[] stack,boolean[] visited,int x,ArrayList<ArrayList<Integer>> arr)
{
if(stack[x])
{
cycle=true;
return;
}
visited[x]=true;
for(int i:arr.get(x))
{
if(!visited[x])
{
cycle(stack,visited,i,arr);
}
}
stack[x]=false;
}
public static int check(char[][] ch,int x,int y)
{
int cnt=0;
int c=0;
int N=ch.length;
int x1=x,y1=y;
while(c<ch.length)
{
if(ch[x][y]=='1')
++cnt;
// if(x1==0 && y1==3)
// System.out.println(x+" "+y+" "+cnt);
x=(x+1)%N;
y=(y+1)%N;
++c;
}
return cnt;
}
public static void s(char[][] arr,int x)
{
char start=arr[arr.length-1][x];
for(int i=arr.length-1;i>0;i--)
{
arr[i][x]=arr[i-1][x];
}
arr[0][x]=start;
}
public static void shuffle(char[][] arr,int x,int down)
{
int N= arr.length;
down%=N;
char[] store=new char[N-down];
for(int i=0;i<N-down;i++)
store[i]=arr[i][x];
for(int i=0;i<arr.length;i++)
{
if(i<down)
{
// Printing rightmost
// kth elements
arr[i][x]=arr[N + i - down][x];
}
else
{
// Prints array after
// 'k' elements
arr[i][x]=store[i-down];
}
}
}
public static String form(int C1,char ch1,char ch2)
{
char ch=ch1;
String s="";
for(int i=1;i<=C1;i++)
{
s+=ch;
if(ch==ch1)
ch=ch2;
else
ch=ch1;
}
return s;
}
public static void printArray(long[] arr)
{
for(int i=0;i<arr.length;i++)
System.out.print(arr[i]+" ");
System.out.println();
}
public static boolean check(long mid,long[] arr,long K)
{
long[] arr1=Arrays.copyOfRange(arr,0,arr.length);
long ans=0;
for(int i=0;i<arr1.length-1;i++)
{
if(arr1[i]+arr1[i+1]>=mid)
{
long check=(arr1[i]+arr1[i+1])/mid;
// if(mid==5)
// System.out.println(check);
long left=check*mid;
left-=arr1[i];
if(left>=0)
arr1[i+1]-=left;
ans+=check;
}
// if(mid==5)
// printArray(arr1);
}
// if(mid==5)
// System.out.println(ans);
ans+=arr1[arr1.length-1]/mid;
return ans>=K;
}
public static long search(long sum,long[] arr,long K)
{
long l=1,r=sum/K;
while(l<=r)
{
long mid=(l+r)/2;
if(check(mid,arr,K))
{
if(mid+1<=sum/K && check(mid+1,arr,K))
l=mid+1;
else
return mid;
}
else
r=mid-1;
}
return -1;
}
public static void primeFactors(int n,HashSet<Integer> hp)
{
// Print the number of 2s that divide n
ArrayList<Integer> factors=new ArrayList<>();
if(n%2==0)
hp.add(2);
while (n%2==0)
{
n /= 2;
}
// n must be odd at this point. So we can
// skip one element (Note i = i +2)
for (int i = 3; i <= Math.sqrt(n); i+= 2)
{
// While i divides n, print i and divide n
if(n%i==0)
hp.add(i);
while (n%i == 0)
{
n /= i;
}
}
// This condition is to handle the case when
// n is a prime number greater than 2
if (n > 2)
{
hp.add(n);
}
}
public static boolean check(String s)
{
HashSet<Character> hp=new HashSet<>();
char ch=s.charAt(0);
for(int i=1;i<s.length();i++)
{
// System.out.println(hp+" "+s.charAt(i));
if(hp.contains(s.charAt(i)))
{
// System.out.println(i);
// System.out.println(hp);
// System.out.println(s.charAt(i));
return false;
}
if(s.charAt(i)!=ch)
{
hp.add(ch);
ch=s.charAt(i);
}
}
return true;
}
public static int check_end(String[] arr,boolean[] st,char ch)
{
for(int i=0;i<arr.length;i++)
{
if(ch==arr[i].charAt(0) && !st[i] && ch==arr[i].charAt(arr[i].length()-1))
return i;
}
for(int i=0;i<arr.length;i++)
{
if(ch==arr[i].charAt(0) && !st[i])
return i;
}
return -1;
}
public static int check_start(String[] arr,boolean[] st,char ch)
{
for(int i=0;i<arr.length;i++)
{
// if(ch=='B')
// {
// if(!st[i])
// System.out.println(arr[i]+" hello");
// }
if(ch==arr[i].charAt(arr[i].length()-1) && !st[i] && ch==arr[i].charAt(0))
return i;
}
for(int i=0;i<arr.length;i++)
{
// if(ch=='B')
// {
// if(!st[i])
// System.out.println(arr[i]+" hello");
// }
if(ch==arr[i].charAt(arr[i].length()-1) && !st[i])
return i;
}
return -1;
}
public static boolean palin(int N)
{
String s="";
while(N>0)
{
s+=N%10;
N/=10;
}
int l=0,r=s.length()-1;
while(l<=r)
{
if(s.charAt(l)!=s.charAt(r))
return false;
++l;
--r;
}
return true;
}
public static boolean check(long org_s,long org_d,long org_n,long check_ele)
{
if(check_ele<org_s)
return false;
if((check_ele-org_s)%org_d!=0)
return false;
long num=(check_ele-org_s)/org_d;
// if(check_ele==5)
// System.out.println(num+" "+org_n);
return num+1<=org_n;
}
public static long check(long c,long c_diff,long mod,long b_start,long c_start, long c_end,long b_end,long b_diff)
{
// System.out.println(c);
long max=Math.max(c,b_diff);
long min=Math.min(c,b_diff);
long lcm=(max/gcd(max,min))*min;
// System.out.println(lcm);
// System.out.println(c);
// System.out.println(c_diff);
// if(b_diff>c)
// {
long start_point=c_diff/c-c_diff/lcm;
// System.out.println(start_point);
// }
// else
// {
// start_point=c_diff/b_diff-c_diff/c;
// }
// System.out.println(c+" "+start_point);
return (start_point%mod*start_point%mod)%mod;
}
public static boolean check_bounds(int x,int y,int[][] arr,int N,int M)
{
return x>=0 && x<N && y>=0 && y<M && (arr[x][y]==1 || arr[x][y]==9);
}
static boolean found=false;
public static void check(int x,int y,int[][] arr,boolean status[][])
{
if(arr[x][y]==9)
{
found=true;
return;
}
status[x][y]=true;
if(check_bounds(x-1,y,arr,arr.length,arr[0].length)&& !status[x-1][y])
check(x-1,y,arr,status);
if(check_bounds(x+1,y,arr,arr.length,arr[0].length)&& !status[x+1][y])
check(x+1,y,arr,status);
if(check_bounds(x,y-1,arr,arr.length,arr[0].length)&& !status[x][y-1])
check(x,y-1,arr,status);
if(check_bounds(x,y+1,arr,arr.length,arr[0].length)&& !status[x][y+1])
check(x,y+1,arr,status);
}
public static int check(String s1,String s2,int M)
{
int ans=0;
for(int i=0;i<M;i++)
{
ans+=Math.abs(s1.charAt(i)-s2.charAt(i));
}
return ans;
}
public static int check(int[][] arr,int dir1,int dir2,int x1,int y1)
{
int sum=0,N=arr.length,M=arr[0].length;
int x=x1+dir1,y=y1+dir2;
while(x<N && x>=0 && y<M && y>=0)
{
sum+=arr[x][y];
x=x+dir1;
y+=dir2;
}
return sum;
}
public static int check(long[] pref,long X,int N)
{
if(X>pref[N-1])
return -1;
// System.out.println(pref[0]);
if(X<=pref[0])
return 1;
int l=0,r=N-1;
while(l<=r)
{
int mid=(l+r)/2;
if(pref[mid]>=X)
{
if(mid-1>=0 && pref[mid-1]<X)
return mid+1;
else
r=mid-1;
}
else
l=mid+1;
}
return -1;
}
private static long mergeAndCount(int[] arr, int l,
int m, int r)
{
// Left subarray
int[] left = Arrays.copyOfRange(arr, l, m + 1);
// Right subarray
int[] right = Arrays.copyOfRange(arr, m + 1, r + 1);
int i = 0, j = 0, k = l;long swaps = 0;
while (i < left.length && j < right.length) {
if (left[i] < right[j])
arr[k++] = left[i++];
else {
arr[k++] = right[j++];
swaps += (m + 1) - (l + i);
}
}
while (i < left.length)
arr[k++] = left[i++];
while (j < right.length)
arr[k++] = right[j++];
return swaps;
}
// Merge sort function
private static long mergeSortAndCount(int[] arr, int l,
int r)
{
// Keeps track of the inversion count at a
// particular node of the recursion tree
long count = 0;
if (l < r) {
int m = (l + r) / 2;
// Total inversion count = left subarray count
// + right subarray count + merge count
// Left subarray count
count += mergeSortAndCount(arr, l, m);
// Right subarray count
count += mergeSortAndCount(arr, m + 1, r);
// Merge count
count += mergeAndCount(arr, l, m, r);
}
return count;
}
public static long check(long L,long R)
{
long ans=0;
for(int i=1;i<=Math.pow(10,8);i++)
{
long A=i*(long)i;
if(A<L)
continue;
long upper=(long)Math.floor(Math.sqrt(A-L));
long lower=(long)Math.ceil(Math.sqrt(Math.max(A-R,0)));
if(upper>=lower)
ans+=upper-lower+1;
}
return ans;
}
public static int check(ArrayList<ArrayList<Integer>> arr,int x,int parent,int[]store)
{
int index=0;
ArrayList<Integer> temp=arr.get(x);
for(int i:temp)
{
if(i!=parent)
{
index+=check(arr,i,x,store);
}
}
store[x]=index;
return index+1;
}
public static void finans(int[][] store,ArrayList<ArrayList<Integer>> arr,int x,int parent)
{
// ++delete;
// System.out.println(x);
if(store[x][0]==0 && store[x][1]==0)
return;
if(store[x][0]!=0 && store[x][1]==0)
{
++delete;
ans+=store[x][0];
return;
}
if(store[x][0]==0 && store[x][1]!=0)
{
++delete;
ans+=store[x][1];
return;
}
ArrayList<Integer> temp=arr.get(x);
if(store[x][0]!=0 && store[x][1]!=0)
{
++delete;
if(store[x][0]>store[x][1])
{
ans+=store[x][0];
for(int i=temp.size()-1;i>=0;i--)
{
if(temp.get(i)!=parent)
{
finans(store,arr,temp.get(i),x);
break;
}
}
}
else
{
ans+=store[x][1];
for(int i=0;i<temp.size();i++)
{
if(temp.get(i)!=parent)
{
finans(store,arr,temp.get(i),x);
break;
}
}
}
}
}
public static int dfs(ArrayList<ArrayList<Integer>> arr,int x,int parent,int[] store)
{
int index1=-1,index2=-1;
for(int i=0;i<arr.get(x).size();i++)
{
if(arr.get(x).get(i)!=parent)
{
if(index1==-1)
{
index1=i;
}
else
index2=i;
}
}
if(index1==-1)
{
return 0;
}
if(index2==-1)
{
return store[arr.get(x).get(index1)];
}
// System.out.println(x);
// System.out.println();;
return Math.max(store[arr.get(x).get(index1)]+dfs(arr,arr.get(x).get(index2),x,store),store[arr.get(x).get(index2)]+dfs(arr,arr.get(x).get(index1),x,store));
}
static int delete=0;
public static boolean bounds(int x,int y,int N,int M)
{
return x>=0 && x<N && y>=0 && y<M;
}
public static int gcd_check(ArrayList<Integer> temp,char[] ch, int[] arr)
{
ArrayList<Integer> ini=new ArrayList<>(temp);
for(int i=0;i<temp.size();i++)
{
for(int j=0;j<temp.size();j++)
{
int req=temp.get(j);
temp.set(j,arr[req-1]);
}
boolean status=true;
for(int j=0;j<temp.size();j++)
{
if(ch[ini.get(j)-1]!=ch[temp.get(j)-1])
status=false;
}
if(status)
return i+1;
}
return temp.size();
}
static long LcmOfArray(int[] arr, int idx)
{
// lcm(a,b) = (a*b/gcd(a,b))
if (idx == arr.length - 1){
return arr[idx];
}
int a = arr[idx];
long b = LcmOfArray(arr, idx+1);
return (a*b/gcd(a,b)); //
}
public static boolean check(ArrayList<Integer> arr,int sum)
{
for(int i=0;i<arr.size();i++)
{
for(int j=i+1;j<arr.size();j++)
{
for(int k=j+1;k<arr.size();k++)
{
if(arr.get(i)+arr.get(j)+arr.get(k)==sum)
return true;
}
}
}
return false;
}
public static void check(ArrayList<ArrayList<Integer>> arr,int x,int parent,long[] l,long[] r,int[] left,int[] right)
{
if(arr.get(x).size()==1 && x!=0)
{
l[x]=left[x];
r[x]=right[x];
++ans;
return;
}
long l1=0,r1=0;
for(int i:arr.get(x))
{
if(i!=parent)
{
check(arr,i,x,l,r,left,right);
l1+=l[i];
r1+=r[i];
}
}
// System.out.println(l1+" "+r1);
if(r1<left[x])
{
l[x]=left[x];
r[x]=right[x];
++ans;
}
else
{
l[x]=Math.max(l1,left[x]);
r[x]=Math.min(r1,right[x]);
}
}
// Returns true if str1 is smaller than str2.
static boolean isSmaller(String str1, String str2)
{
// Calculate lengths of both string
int n1 = str1.length(), n2 = str2.length();
if (n1 < n2)
return true;
if (n2 < n1)
return false;
for (int i = 0; i < n1; i++)
if (str1.charAt(i) < str2.charAt(i))
return true;
else if (str1.charAt(i) > str2.charAt(i))
return false;
return false;
}
public static void transform(List<Integer> arr)
{
}
public static int check(List<String> history)
{
int[][] arr=new int[history.size()][history.get(0).length()];
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr[0].length;j++)
{
arr[i][j]=history.get(i).charAt(j)-48;
}
}
for(int i=0;i<arr.length;i++)
Arrays.sort(arr[i]);
int sum=0;
for(int i=0;i<arr[0].length;i++)
{
int max=0;
for(int j=0;j<arr.length;j++)
max=Math.max(max,arr[j][i]);
sum+=max;
}
return sum;
}
// Function for find difference of larger numbers
static String findDiff(String str1, String str2)
{
// Before proceeding further, make sure str1
// is not smaller
if (isSmaller(str1, str2)) {
String t = str1;
str1 = str2;
str2 = t;
}
// Take an empty string for storing result
String str = "";
// Calculate length of both string
int n1 = str1.length(), n2 = str2.length();
// Reverse both of strings
str1 = new StringBuilder(str1).reverse().toString();
str2 = new StringBuilder(str2).reverse().toString();
int carry = 0;
// Run loop till small string length
// and subtract digit of str1 to str2
for (int i = 0; i < n2; i++) {
// Do school mathematics, compute difference of
// current digits
int sub
= ((int)(str1.charAt(i) - '0')
- (int)(str2.charAt(i) - '0') - carry);
// If subtraction is less then zero
// we add then we add 10 into sub and
// take carry as 1 for calculating next step
if (sub < 0) {
sub = sub + 10;
carry = 1;
}
else
carry = 0;
str += (char)(sub + '0');
}
// subtract remaining digits of larger number
for (int i = n2; i < n1; i++) {
int sub = ((int)(str1.charAt(i) - '0') - carry);
// if the sub value is -ve, then make it
// positive
if (sub < 0) {
sub = sub + 10;
carry = 1;
}
else
carry = 0;
str += (char)(sub + '0');
}
// reverse resultant string
return new StringBuilder(str).reverse().toString();
}
public static boolean check(int x,int parent,ArrayList<ArrayList<Integer>> arr,int[] values,int y)
{
if(x==y)
{
ans=values[x];
return true;
}
boolean status=false;
for(int i:arr.get(x))
{
if(i!=parent)
{
status= status || check(i,x,arr,values,y);
}
}
if(status)
ans=Math.max(ans,values[x]);
return status;
}
public static boolean color(HashMap<Integer,Long> hp,int time,int N,int M)
{
long rem_task=0;
long spare=N-hp.size();
rem_task+=spare*(time/2);
long req=0;
for(int i:hp.keySet())
{
if(hp.get(i)>time)
{
req+=hp.get(i)-time;
}
else
{
rem_task+=(time-hp.get(i))/2;
}
}
// System.out.println(time+" "+rem_task+" "+req);
return rem_task>=req;
}
public static int check(HashMap<Integer,Long> hp,int N,int M)
{
int l=1,r=M;
while(l<=r)
{
int mid=(l+r)/2;
if(color(hp,mid,N,M))
{
if(mid-1>=1 && color(hp,mid-1,N,M))
r=mid-1;
else
return mid;
}
else
l=mid+1;
}
return -1;
}
public static void fill(int x,int parent,ArrayList<ArrayList<Integer>> arr,int d,int[] dist)
{
dist[x]=d;
for(int i:arr.get(x))
{
if(i!=parent)
{
fill(i,x,arr,d+1,dist);
}
}
}
public static boolean collect(int x,int parent,ArrayList<ArrayList<Integer>> arr,int d,int[] dist,int[] coins)
{
if(x==0)
{
if(dist[x]>d/2)
coins[x]=0;
if(d%2==0 && dist[x]==d/2)
{
coins[x]/=2;
}
return true;
}
for(int i:arr.get(x))
{
if(i!=parent)
{
boolean status=collect(i,x,arr,d,dist,coins);
if(status)
{
if(dist[x]>d/2)
coins[x]=0;
if(d%2==0 && dist[x]==d/2)
{
coins[x]/=2;
}
return true;
}
}
}
return false;
}
public static void answer(int x,int parent,ArrayList<ArrayList<Integer>> arr,int[] coins,int c)
{
if(arr.get(x).size()==1 && x!=0)
{
ans=Math.max(ans,coins[x]+c);
return;
}
for(int i:arr.get(x))
{
if(i!=parent)
{
answer(i,x,arr,coins,coins[x]+c);
}
}
}
static int nCr(int n, int r)
{
return fact(n) / (fact(r) *
fact(n - r));
}
// Returns factorial of n
static int fact(int n)
{
int res = 1;
for (int i = 2; i <= n; i++)
res = res * i;
return res;
}
public static void main(String[] args) throws IOException {
Reader.init(System.in);
BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
int T=Reader.nextInt();
for(int m=1;m<=T;m++)
{
int N=Reader.nextInt();
int l=Reader.nextInt();
int r=Reader.nextInt();
int[] ans=new int[N+1];
boolean status=true;
for(int i=1;i<=N;i++)
{
int left=(l+i-1)/i;
int right=(r/i);
if(left<=right)
ans[i]=left*i;
else
status=false;
}
if(status)
{
output.write("YES"+"\n");
for(int i=1;i<=N;i++)
output.write(ans[i]+" ");
output.write("\n");
}
else
output.write("NO"+"\n");
}
output.flush();
}
}
class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
static void init(InputStream input) {
reader = new BufferedReader(
new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(
reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static long nextLong() throws IOException {
return Long.parseLong(next());
}
static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
}
class TreeNode
{
int data;
TreeNode left;
TreeNode right;
TreeNode(int data)
{
left=null;
right=null;
this.data=data;
}
}
class div {
int x;
int y;
int z;
div(int x,int y,int z) {
this.x=x;
this.y=y;
this.z=z;
}
}
class trie_node
{
trie_node[] arr;
trie_node()
{
arr=new trie_node[26];
}
public static void insert(trie_node root,String s)
{
trie_node tmp=root;
for(int i=0;i<s.length();i++)
{
if(tmp.arr[s.charAt(i)-97]!=null)
{
tmp=tmp.arr[s.charAt(i)-97];
}
else
{
tmp.arr[s.charAt(i)-97]=new trie_node();
tmp=tmp.arr[s.charAt(i)-97];
}
}
}
public static boolean search(trie_node root,String s)
{
trie_node tmp=root;
for(int i=0;i<s.length();i++)
{
if(tmp.arr[s.charAt(i)-97]!=null)
{
tmp=tmp.arr[s.charAt(i)-97];
}
else
{
return false;
}
}
return true;
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 6fe2a3c95d58fb94f84bde4ad18302a9 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*; import java.util.*;
public class cf {
public static void main(String [] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
while (t-->0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
long l = Integer.parseInt(st.nextToken());
long r = Integer.parseInt(st.nextToken());
String print = "YES";
long[] ans = new long[n];
for(int i=n; i>0; i--) {
long test = l;
if (test%i!=0&&test>i) {
test+=i-l%i;
}
else if (test%i!=0&&test<i){
test=i;
}
if (test>r) {
print="NO";
break;
}
ans[i-1]=test;
}
pw.println(print);
if(print.equals("YES")) {
for(int i=0; i<n; i++) {
pw.print(ans[i]+" ");
}
pw.println();
}
}
pw.close();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 1163f909434f0e9419eabc474db956a1 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class B {
public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
PrintWriter pw = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
for(int i = 0; i < t; i++) {
ArrayList<Integer> input = read();
int n = input.get(0);
int l = input.get(1);
int r = input.get(2);
ArrayList<Integer> result = solve(n, l, r);
if(result == null) pw.println("NO");
else {
pw.println("YES");
for(int j = 0; j < n; j++) {
pw.print(result.get(j) + " ");
}
pw.println();
}
}
pw.close();
}
public static ArrayList<Integer> solve(int n, int l, int r) {
ArrayList<Integer> result = new ArrayList<>();
for(int i = 1; i <= n; i++) {
int min = ((l-1)/i + 1) * i;
if(min > r) {
return null;
} else {
result.add(min);
}
}
return result;
}
public static ArrayList<Integer> read() throws IOException {
ArrayList<Integer> result = new ArrayList<>();
StringTokenizer st = new StringTokenizer(br.readLine());
for(int i = 0; i < 3; i++) {
result.add(Integer.parseInt(st.nextToken()));
}
return result;
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 8793c5269b7d65aebf0e9cd9866303c6 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes |
// 20:18 ; 2'50" ; %%I02V2L4L //
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class C {
static class pair implements Comparable<pair> {
int a;
int b;
pair(int a, int b) {
this.a = a;
this.b = b;
}
public int compareTo(pair o) {
return this.a - o.a;
}
}
static HashSet<Integer> al;
static boolean vis[];
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int tt = sc.nextInt();
o: while (tt-- > 0) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
int a[] = new int[n + 1];
a[1] = l;
for (int i = 2; i <= n; i++) {
int x = l;
boolean f = false;
while (x <= r) {
if (x % i == 0) {
a[i] = x;
f = true;
break;
} else {
int y = i - (x) % i;
x += y;
}
}
if (!f) {
System.out.println("NO");
continue o;
}
}
System.out.println("YES");
for (int i = 1; i < n + 1; i++) {
System.out.print(a[i] + " ");
}
System.out.println();
}
}
static void sort(int[] a) {
// ruffle
int n = a.length;
Random r = new Random();
for (int i = 0; i < a.length; i++) {
int oi = r.nextInt(n), temp = a[i];
a[i] = a[oi];
a[oi] = temp;
}
// then sort
Arrays.sort(a);
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String str = "";
String nextLine() {
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
long[] readLongArray(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
static long gcd(long n, long l) {
if (l == 0)
return n;
return gcd(l, n % l);
}
static void sieveOfEratosthenes(int n) {
// Create a boolean array "prime[0..n]" and initialize
// all entries it as true. A value in prime[i] will
// finally be false if i is Not a prime, else true.
boolean prime[] = new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++) {
// If prime[p] is not changed, then it is a prime
if (prime[p] == true) {
// Update all multiples of p
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
for (int i = 2; i <= n; i++) {
if (prime[i] == true)
al.add(i);
}
}
static final int mod = 1_000_000_000 + 7;
static final int max_val = 2147483647;
static final int min_val = max_val + 1;
static long fastPow(long base, long exp) {
if (exp == 0)
return 1;
long half = fastPow(base, exp / 2);
if (exp % 2 == 0)
return mul(half, half);
return mul(half, mul(half, base));
}
static long mul(long a, long b) {
return a * b % mod;
}
static int nCr(int n, int r) {
return fact(n) / (fact(r) *
fact(n - r));
}
static int fact(int n) {
int res = 1;
for (int i = 2; i <= n; i++)
res = res * i;
return res;
}
// a -> z == 97 -> 122
// String.format("%.9f", ans) ,--> to get upto 9 decimal places , (ans is
// double)
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | b27df50ddb2bf89d066ddc50d7fef29b | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.stream.IntStream;
public class Codeforces extends PrintWriter {
Codeforces() { super(System.out); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
Codeforces o = new Codeforces(); o.main(); o.flush();
o.close();
}
final int mod = 998244353;
// static int maxRepeat(int arr[], int n)
// {
// Map<Integer,Integer> map = new HashMap<>();
// for(int v: arr){
// map.put(v,map.getOrDefault(v,0)+1);
// }
// int max=0;
// for(Integer val: map.values()){
// max=Math.max(max,val);
// }
// if(max>2)
// return getKey(map,max);
// else
// return -1;
// }
void solve(){
}
void main() {
int t = sc.nextInt();
while (t--> 0) {
// int arr[] = new int[n];
// for(int i=0;i<n;i++){
// arr[i]=sc.nextInt();
// }
//Arrays.sort(arr);
ArrayList<Integer> arr = new ArrayList<>();
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
int val=0;
boolean flag=true;
for(int i=1;i<=n;i++){
val = (r/i)*i;
if(val>=l && val<=r) arr.add(val);
else{
flag=false;
}
}
//println(arr);
if(flag){
println("YES");
for(int a: arr){
print(a+" ");
}
println();
}
else{
println("NO");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | f3ecd2344df0caa802713147eb877576 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | //package com.company;
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t;
t = sc.nextInt();
loop1: for (int i = 0; i < t; i++) {
int n,l,r;
String res = "NO";
n = sc.nextInt();
l = sc .nextInt();
r = sc.nextInt();
int a[] = new int[n];
for(int j = 0; j <n;j++) {
int q = (int)Math.ceil((l*1.0)/(j+1));
int mul = q*(j+1);
if(mul <= r)
a[j] = mul;
else {
System.out.println("NO");
continue loop1;
}
}
System.out.println("YES");
for(int j = 0; j < n;j++)
System.out.print(a[j]+" ");
System.out.println();
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 8bfcacc6aacf7b2619860ee961cf9a24 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int[] arr = new int[n];
int l = sc.nextInt();
int r = sc.nextInt();
n--;
while(n>=0){
int rr = r;
while((rr%(n+1))!=0 && rr>=l){
int rem = rr%(n+1);
rr=rr-rem;
}
if(rr<l){
System.out.println("NO");
break;
}
arr[n]=rr;
n--;
}
if(n<0){
System.out.println("YES");
for(int i = 0; i<arr.length; i++){
System.out.print(arr[i]+" ");
}
System.out.println();
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | b8a85a42f3456c8e0ac44f3861bc17ed | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.System.in;
import static java.lang.System.out;
public class B {
public static void println (Object o) {System.out.println(o);}
public static void print (Object o) {System.out.print(o);}
// Pair<Integer, Integer> pair=new Pair<>();
// Map<Integer, Integer> map=new HashMap<>();
// Set<Integer> set=new HashSet<>();
// ArrayList<Integer> ls=new ArrayList<>();
public static void main(String[] args) {
FScanner sc=new FScanner();
PrintWriter out=new PrintWriter(System.out);
int T=sc.nextInt();
while(T-->0) {
int n=sc.nextInt();
long l=sc.nextInt(), r=sc.nextInt();
ArrayList<Integer> ls=new ArrayList<>(n);
boolean fl=true;
for(int i=1; i<=n; i++){
long temp=(r/i)*i;
if(temp>=l){
ls.add((int)temp);
} else {
fl=false;
println("No");
break;
}
}
if(fl) {
println("Yes");
for (int i : ls) {
print(i + " ");
}
println("");
}
}
out.close();
}
static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
static class FScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 11f0f00e8ee38eaa4d5a8059dcb14395 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | // Author - Diwakar Singh
import java.io.*;
import java.util.*;
import java.math.*;
// fastPower(int a, int n) --> Power of a number
// cnt_div(int n) --> count divisors
public class Main
{
static PrintWriter out=new PrintWriter((System.out));
// recursive implementation
// public static solver(int n){
// return n;
// }
// long q=sc.nextLong(), count=0, max=0, temp=q;
// int arr[] = new int[n];
// StringBuilder sb = new StringBuilder();
// count=q;
// for(int i=0;i<n;i++){
// arr[i]=sc.nextInt();
// if(arr[i]<=q) count++;
// else{
// max = Math.max(count, max);
// index=i;
// count=0;
// }
// }
// for(int i=0;i<n;i++){
// if(i<index-max+1 && arr[i]>q) sb.append("0");
// else if(i<index-max+1 && arr[i]<=q) sb.append("1");
// else if(i>=index-max+1 && arr[i]<=q) sb.append("1");
// else if(temp>0 && i>=index-max+1 && arr[i]>q){
// sb.append("1");
// temp--;
// }
// }
// out.println(sb.toString());
public static void main(String args[])throws IOException
{
Reader sc=new Reader();
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int arr[] = new int[n];
int l =sc.nextInt(), r=sc.nextInt();
boolean flag = true;
for(int i=1;i<=n;i++){
int low=l/i;
int high=r/i;
low*=i;
high*=i;
if(high<l || low>r){
flag=false;
break;
}
else{
arr[i-1]=high;
}
}
if(flag==false) out.println("NO");
else{
out.println("YES");
for(int i=0;i<arr.length;i++){
out.print(arr[i]+" ");
}
out.println();
}
}
out.close();
}
// ---------------------------------------------------------------
// static int __gcd(int a, int b)
// {
// return b == 0? a:__gcd(b, a % b);
// }
// static int GcdOfArray(int[] arr, int idx)
// {
// if (idx == arr.length - 1) {
// return arr[idx];
// }
// int a = arr[idx];
// int b = GcdOfArray(arr, idx + 1);
// return __gcd(a, b); // __gcd(a,b) is inbuilt library function
// }
// static int fastPower(int a, int n){
// if(n==0) return 1;
// if(n==1) return a;
// if((n&1)==1) return a*fastPower(a, n/2)*fastPower(a, n/2);
// return fastPower(a,n/2)*fastPower(a, n/2);
// }
// static boolean prime(int n){
// int count=0;
// for(int i=1;i*i<=n;i++){
// if(n%i==0){
// count++;
// if(i!=n/i) count++;
// }
// if(count>2) return false;
// }
// return true;
// }
static class Reader
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
public String next()
{
while(!st.hasMoreTokens())
{
try
{
st=new StringTokenizer(br.readLine());
}
catch(Exception e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
public int nextInt()
{
return Integer.parseInt(next());
}
public long nextLong()
{
return Long.parseLong(next());
}
public double nextDouble()
{
return Double.parseDouble(next());
}
public String nextLine()
{
try
{
return br.readLine();
}
catch(Exception e)
{
e.printStackTrace();
}
return null;
}
public boolean hasNext()
{
String next=null;
try
{
next=br.readLine();
}
catch(Exception e)
{
}
if(next==null)
{
return false;
}
st=new StringTokenizer(next);
return true;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | aa151b3a4b207fa09bb1055ae7d32526 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{ static int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int n=sc.nextInt();
int l=sc.nextInt();
int r=sc.nextInt();
if(n==1){
System.out.println("YES");
System.out.println(l);
continue;
}
long[] arr=new long[n];
int check=0;
StringBuilder str
= new StringBuilder("");
for(int j=0;j<n;j++){
long rr=l%(j+1);
if(l<(j+1)){
rr=j+1-l;
}
if(rr==0){
arr[j]=l;
}
else{
if(l>(j+1)){
arr[j]=l+(j+1)-rr;
}
else{
arr[j]=l+rr;
}
if(arr[j]>r){
check=1;
break;
}
}
str.append(arr[j]+" ");
}
if(check==1){
System.out.println("NO");
}
else{
System.out.println("YES");
System.out.println(str.toString());
}
}
// your code goes here
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 11 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 616f0e62ea72dc8934d7cdede7e08125 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{
static final PrintWriter out =new PrintWriter(System.out);
static final FastReader sc = new FastReader();
//I invented a new word!Plagiarism!
//Did you hear about the mathematician who’s afraid of negative numbers?He’ll stop at nothing to avoid them
//What do Alexander the Great and Winnie the Pooh have in common? Same middle name.
//I finally decided to sell my vacuum cleaner. All it was doing was gathering dust!
//ArrayList<Integer> a=new ArrayList <Integer>();
//char[] a = s.toCharArray();
public static void main (String[] args) throws java.lang.Exception
{ int tes=sc.nextInt();
while(tes-->0)
{
int n=sc.nextInt();
int l=sc.nextInt();
int r=sc.nextInt();
int i,f=1;
for(i=1;i<=n;i++)
{
if((r/i*i)<l)
{
f=0;
break;
}
}
if(f==0){
System.out.println("No");
continue;
}
System.out.println("Yes");
for(i=1;i<=n;i++)
System.out.print(r/i*i+" ");
System.out.println();
}
}
public static int lis(int[] arr) {
int n = arr.length;
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(arr[0]);
for(int i = 1 ; i<n;i++) {
int x = al.get(al.size()-1);
if(arr[i]>=x) {
al.add(arr[i]);
}else {
int v = upper_bound(al, 0, al.size(), arr[i]);
al.set(v, arr[i]);
}
}
return al.size();
}
public static int lower_bound(ArrayList<Integer> ar,int lo , int hi , int k)
{
int s=lo;
int e=hi;
while (s !=e)
{
int mid = s+e>>1;
if (ar.get(mid) <k)
{
s=mid+1;
}
else
{
e=mid;
}
}
if(s==ar.size())
{
return -1;
}
return s;
}
public static int upper_bound(ArrayList<Integer> ar,int lo , int hi, int k)
{
int s=lo;
int e=hi;
while (s !=e)
{
int mid = s+e>>1;
if (ar.get(mid) <=k)
{
s=mid+1;
}
else
{
e=mid;
}
}
if(s==ar.size())
{
return -1;
}
return s;
}
static boolean isPrime(long N)
{
if (N<=1) return false;
if (N<=3) return true;
if (N%2 == 0 || N%3 == 0) return false;
for (int i=5; i*i<=N; i=i+6)
if (N%i == 0 || N%(i+2) == 0)
return false;
return true;
}
static int countBits(long a)
{
return (int)(Math.log(a)/Math.log(2)+1);
}
static long fact(long N)
{
long mod=1000000007;
long n=2;
if(N<=1)return 1;
else
{
for(int i=3; i<=N; i++)n=(n*i)%mod;
}
return n;
}
private static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException e) {
return false;
} catch (NullPointerException e) {
return false;
}
return true;
}
private static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
private static long lcm(long a, long b) {
return (a / gcd(a, b)) * b;
}
private static boolean isPalindrome(String str) {
int i = 0, j = str.length() - 1;
while (i < j)
if (str.charAt(i++) != str.charAt(j--))
return false;
return true;
}
private static String reverseString(String str) {
StringBuilder sb = new StringBuilder(str);
return sb.reverse().toString();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 6030ff11e690168aa3f31a05a7010c75 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{
static final PrintWriter out =new PrintWriter(System.out);
static final FastReader sc = new FastReader();
//I invented a new word!Plagiarism!
//Did you hear about the mathematician who’s afraid of negative numbers?He’ll stop at nothing to avoid them
//What do Alexander the Great and Winnie the Pooh have in common? Same middle name.
//I finally decided to sell my vacuum cleaner. All it was doing was gathering dust!
//ArrayList<Integer> a=new ArrayList <Integer>();
//char[] a = s.toCharArray();
public static void main (String[] args) throws java.lang.Exception
{ int tes=sc.nextInt();
while(tes-->0)
{
int n=sc.nextInt();
int l=sc.nextInt();
int r=sc.nextInt();
int i,f=1;
for(i=1;i<=n;i++)
{
if((r/i*i)<l)
{
f=0;
break;
}
}
if(f==0){
System.out.println("NO");
continue;
}
System.out.println("Yes");
for(i=1;i<=n;i++)
System.out.print(r/i*i+" ");
System.out.println();
}
}
public static int lis(int[] arr) {
int n = arr.length;
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(arr[0]);
for(int i = 1 ; i<n;i++) {
int x = al.get(al.size()-1);
if(arr[i]>=x) {
al.add(arr[i]);
}else {
int v = upper_bound(al, 0, al.size(), arr[i]);
al.set(v, arr[i]);
}
}
return al.size();
}
public static int lower_bound(ArrayList<Integer> ar,int lo , int hi , int k)
{
int s=lo;
int e=hi;
while (s !=e)
{
int mid = s+e>>1;
if (ar.get(mid) <k)
{
s=mid+1;
}
else
{
e=mid;
}
}
if(s==ar.size())
{
return -1;
}
return s;
}
public static int upper_bound(ArrayList<Integer> ar,int lo , int hi, int k)
{
int s=lo;
int e=hi;
while (s !=e)
{
int mid = s+e>>1;
if (ar.get(mid) <=k)
{
s=mid+1;
}
else
{
e=mid;
}
}
if(s==ar.size())
{
return -1;
}
return s;
}
static boolean isPrime(long N)
{
if (N<=1) return false;
if (N<=3) return true;
if (N%2 == 0 || N%3 == 0) return false;
for (int i=5; i*i<=N; i=i+6)
if (N%i == 0 || N%(i+2) == 0)
return false;
return true;
}
static int countBits(long a)
{
return (int)(Math.log(a)/Math.log(2)+1);
}
static long fact(long N)
{
long mod=1000000007;
long n=2;
if(N<=1)return 1;
else
{
for(int i=3; i<=N; i++)n=(n*i)%mod;
}
return n;
}
private static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException e) {
return false;
} catch (NullPointerException e) {
return false;
}
return true;
}
private static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
private static long lcm(long a, long b) {
return (a / gcd(a, b)) * b;
}
private static boolean isPalindrome(String str) {
int i = 0, j = str.length() - 1;
while (i < j)
if (str.charAt(i++) != str.charAt(j--))
return false;
return true;
}
private static String reverseString(String str) {
StringBuilder sb = new StringBuilder(str);
return sb.reverse().toString();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 0ffcfaa4c63b1845d4c6cd60e97f6426 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class R808D2B {
static class InputReader {
public final BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader() {
reader = new BufferedReader(new InputStreamReader(System.in), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public int[] readIntArray(int n) {
int[] x = new int[n];
for (int i = 0; i < n; i++) {
x[i] = nextInt();
}
return x;
}
public int[] readBitString() {
char[] chars = next().toCharArray();
int[] x = new int[chars.length];
for (int i = 0; i < x.length; i++) {
x[i] = chars[i] - '0';
}
return x;
}
public Integer[] readIntegerArray(int n) {
Integer[] x = new Integer[n];
for (int i = 0; i < n; i++) {
x[i] = nextInt();
}
return x;
}
public long[] readLongArray(int n) {
long[] x = new long[n];
for (int i = 0; i < n; i++) {
x[i] = nextLong();
}
return x;
}
public Long[] readLongObjectArray(int n) {
Long[] x = new Long[n];
for (int i = 0; i < n; i++) {
x[i] = nextLong();
}
return x;
}
public double[] readDoubleArray(int n) {
double[] x = new double[n];
for (int i = 0; i < n; i++) {
x[i] = nextDouble();
}
return x;
}
}
static class FastWriter {
BufferedWriter output;
public FastWriter() {
output = new BufferedWriter(
new OutputStreamWriter(System.out));
}
void write(String s) {
try {
output.write(s);
} catch (IOException e) { e.printStackTrace(); }
}
void endLine() {
try {
output.write("\n");
output.flush();
} catch (IOException e) { e.printStackTrace(); }
}
void writeInt(int x) {
write(Integer.toString(x));
endLine();
}
void writeLong(long x) {
write(Long.toString(x));
endLine();
}
void writeLine(String line) {
write(line);
endLine();
}
void writeIntArray(int[] a) {
write(Integer.toString(a[0]));
for (int i = 1; i < a.length; i++) {
write(" "+Integer.toString(a[i]));
}
endLine();
}
void writeLongArray(long[] a) {
write(Long.toString(a[0]));
for (int i = 1; i < a.length; i++) {
write(" "+Long.toString(a[i]));
}
endLine();
}
}
public static class Utility {
public static void safeSort(int[] a) {
shuffle(a);
Arrays.sort(a);
}
public static void safeSort(long[] a) {
shuffle(a);
Arrays.sort(a);
}
public static void shuffle(int[] a) {
Random r = new Random();
for(int i = 0; i < a.length-2; i ++) {
int j = i + r.nextInt(a.length - i);
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
public static void shuffle(long[] a) {
Random r = new Random();
for(int i = 0; i < a.length-2; i ++) {
int j = i + r.nextInt(a.length - i);
long t = a[i];
a[i] = a[j];
a[j] = t;
}
}
public static HashMap<Integer,Integer> primeFactorize(int x) {
HashMap<Integer,Integer> factors = new HashMap();
int f = 2;
int max = (int)Math.sqrt(x);
while(x > 1 && f <= max) {
int c = 0;
while(x%f == 0) {
x /= f;
c += f%2 + 1;
}
if(c > 0)
factors.put(f,c);
f ++;
}
factors.put(x,1);
return factors;
}
}
public static void main(String[] args)
{
InputReader r = new InputReader();
FastWriter w = new FastWriter();
int cases = r.nextInt();
for(int test = 0; test < cases; test ++) {
//INPUT
int n = r.nextInt();
int left = r.nextInt();
int right = r.nextInt();
//CODE
String output = "YES";
int[] a = new int[n];
for(int i = 1; i <= n; i ++) {
int x = left;
if(x%i != 0)
x += (i-x%i);
if(x <= right)
a[i - 1] = x;
else
output = "NO";
}
//END CODE
//OUTPUT
if(output == "YES") {
w.writeLine("YES");
w.writeIntArray(a);
}
else
w.writeLine("NO");
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | e711d1d41f956a4a45b845586cf59968 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes |
import java.util.*;
/**
* @Author Awiiiiii~
* @Data 2022/7/16 0:56
* @Version 1.0
*/
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
//所以gdc[i] = i。这是一定的.
for (int i = 0; i < n; i++) {
int len = sc.nextInt(), l = sc.nextInt(), r = sc.nextInt();
List<Integer> list = new ArrayList<>();
for (int j = len; j >= 1; j--) {
int start = l / j * j + (l % j == 0 ? 0 : j);
if (start >= l && start <= r) list.add(start);
}
if (list.size() < len) System.out.println("NO");
else {
System.out.println("YES");
for (int j = list.size() - 1; j >= 0; j--) {
System.out.print(list.get(j) + " ");
}
}
}
}
public static int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 325c53237cdeb4fbd5c84c5af64338a0 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
public class Main{
public static int[] array(BufferedReader br,int n) throws IOException{
String [] values = br.readLine().split(" ");
int [] arr = new int[n];
for(int i =0; i<n; i++){
arr[i] = Integer.parseInt(values[i]);
}
return arr;
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while(t-->0){
String[] vals = br.readLine().split(" ");
int n = Integer.parseInt(vals[0]);
int l = Integer.parseInt(vals[1]);
int r = Integer.parseInt(vals[2]);
int[] arr = new int[n];
boolean possible = true;
for(int i = 1; i<=n; i++){
int div = l/i;
int check = (div)*i;
if(check<l){
check=(div+1)*i;
}
if(check<=r){
arr[i-1] = check;
}
else{
possible=false;
break;
}
}
if(possible==false){
System.out.println("NO");
}
else{
System.out.println("YES");
StringBuilder sb = new StringBuilder();
for(int i =0; i<n; i++){
sb.append(arr[i] + " ");
}
System.out.println(sb);
}
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | c408cc926f761839c48361c91f72fbe5 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class CF1708B {
// For fast input output
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(
new FileReader("input.txt"));
PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
} catch (Exception e) {
br = new BufferedReader(new InputStreamReader(System.in));
}
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
// end of fast i/o code
public static boolean isPalindrome(String str) {
int i = 0;
int j = str.length() - 1;
int flag = 0;
while (i <= j) {
if (str.charAt(i) != str.charAt(j)) {
flag = 1;
break;
}
i++;
j--;
}
return flag == 1 ? false : true;
}
public static int gcd(int a, int b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
class Pair {
int x1;
int x2;
public Pair(int x1, int x2) {
this.x1 = x1;
this.x2 = x2;
}
}
public static void main(String[] args) {
// System.out.println(gcd(1000,1500));
// System.out.println(gcd(4,1008));
FastReader fs = new FastReader();
int t=fs.nextInt();
while(t-->0){
int n =fs.nextInt();
int l=fs.nextInt();
int r=fs.nextInt();
ArrayList<Integer>ans=new ArrayList<>();
ans.add(l);
int ct=1;
for(int i =2;i<=n;i++){
if(l%i==0)
{
ans.add(l);
ct++;
}
else{
int j=l/i;
j=(j+1)*i;
if(j<=r)
{
ans.add(j);
ct++;
}
}
}
if(ct==n){
System.out.println("YES");
for(int nn:ans)
System.out.print(nn+" ");
System.out.println();
}
else
System.out.println("NO");
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 2591dc37dfa541893fb83c0b424fe83e | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class GCD {
public static int[] f(int x,int y) {
int a[]=new int[x];
for(int j=1;j<=x;j++) a[j-1]=(y/j)*j;
return a;
}
public static void p(int c[]) {
for(int i=0;i<c.length;i++) System.out.print(c[i]+" ");
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t=in.nextInt();
for(int i=1;i<=t;i++) {
int n=in.nextInt();
int l=in.nextInt();
int r=in.nextInt();
int b[]=new int[n];
if(n<(r-l+1)) {
System.out.println("YES");
b=GCD.f(n,r);
GCD.p(b);
}
else {
boolean check=true;
for(int j=1;j<=n;j++) {
if((l/j)*j<l && ((l/j)+1)*j>r) check=false;
}
if(!check) System.out.print("NO");
else {
System.out.println("YES");
b=GCD.f(n,r);
GCD.p(b);
}
}
System.out.println();
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 8edada30fd24a44b393b377829b56956 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.*;
import java.util.*;
public class B {
Input in;
PrintWriter out;
public B() {
in = new Input(System.in);
out = new PrintWriter(System.out);
}
public static void main(String[] args) {
B solution = new B();
for (int t = solution.in.nextInt(); t > 0; t--) {
solution.solve();
}
solution.out.close();
}
void solve() {
int n = in.nextInt();
int l = in.nextInt();
int r = in.nextInt();
StringBuilder sb = new StringBuilder();
for (int i=1; i<=n; i++) {
int temp = l - (l % i);
while (temp < l) temp += i;
if (temp > r) {
out.println("NO");
return;
} else {
sb.append(temp);
sb.append(' ');
}
}
out.println("YES");
out.println(sb);
}
static class Input {
BufferedReader br;
StringTokenizer st;
public Input(InputStream in) {
br = new BufferedReader(new InputStreamReader(in));
st = new StringTokenizer("");
}
String nextString() {
while (!st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(nextString());
}
long nextLong() {
return Long.parseLong(nextString());
}
int[] nextIntArray(int size) {
int[] ans = new int[size];
for (int i = 0; i < size; i++) {
ans[i] = nextInt();
}
return ans;
}
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 07b0a51ab9fdb4a019f58bcda9f906fb | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0) {
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
int[] arr = new int[n];
int max = 0;
for(int i = 0; i < n; i++) {
int x = l%(i + 1);
if(x == 0) arr[i] = l;
else arr[i] = ((l+i+1)-x);
max = Math.max(max, arr[i]);
}
if(max <= r) {
System.out.println("Yes");
for (int i = 0; i < n; i++) System.out.print(arr[i] + " ");
System.out.println();
}
else System.out.println("No");
}
sc.close();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 92f7fd5282d6d5df58990fd5c98479a1 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class B {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader(){
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next(){
while (st == null || !st.hasMoreElements()){
try{
st = new StringTokenizer(br.readLine());
}
catch(IOException e){
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() throws IOException{
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
if(st.hasMoreTokens()){
str = st.nextToken("\n");
}
else{
str = br.readLine();
}
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[] nextArray(int n){
int[] a = new int[n];
for(int i = 0; i < n; i++){
a[i] = Integer.parseInt(next());
}
return a;
}
}
public static void main(String[] args) throws IOException
{
// System.setIn(new FileInputStream(new File("/Users/pluo/Desktop/CF/input.txt")));
// System.setOut(new PrintStream(new File("/Users/pluo/Desktop/CF/output.txt")));
FastReader sc = new FastReader();
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
int tt = sc.nextInt();
for(int a0 = 0; a0 < tt; a0++){
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
boolean ok = true;
int[] a = new int[n+1];
for(int i = 1; i <= n; i++){
if(r/i == l/i && l % i != 0){
ok = false;
break;
}
else{
a[i] = (r/i) * i;
}
}
if(ok){
out.write("YES\n");
for(int i = 1; i <= n; i++){
out.write(a[i] + " ");
}
out.write("\n");
}
else{
out.write("NO\n");
}
}
out.flush();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 4ac7232a5204c7df067ef6fd394c88cc | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class DifferenceOfGCDs {
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int t = scanner.nextInt();
while(t-- > 0) {
solve();
}
}
static void solve() {
int n = scanner.nextInt(), l = scanner.nextInt(), r = scanner.nextInt();
List<Integer> res = new ArrayList();
for(int i = 1;i <= n;i++) {
while(l < i) {
l++;
}
int num = l % i;
if(num == 0) {
if(l <= r) {
res.add(l);
}
else {
System.out.println("NO");
return ;
}
}
else {
if(l + i - num > r) {
System.out.println("NO");
return ;
}
else {
res.add(l + i - num);
}
}
}
System.out.println("YES");
for(int i = 0;i < n;i++) {
System.out.print(res.get(i) + " ");
}
System.out.println();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 7922482357bfd95777b520ecf6336b2c | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
public class B_Difference_of_GCDs{
static int gcd(int a, int b){
if(a == 0)
return b;
return gcd(b % a, a);
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- != 0){
int n = sc.nextInt(), l = sc.nextInt(), r = sc.nextInt();
l -= 1;
int arr[] = new int[n];
boolean flag= false;
for(int i = 1; i <= n; i++){
int rem = l % i;
arr[i - 1] = l + i - rem;
if(arr[i - 1] > r){
flag = true;
break;
}
}
if(flag){
System.out.println("NO");
continue;
}
System.out.println("YES");
for(int x : arr)
System.out.print(x + " ");
System.out.println();
}
sc.close();
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 6c3e7c2f995dd41770918ffc502e9226 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.Scanner;
import java.lang.Math;
import java.math.BigInteger;
public class B {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
int t = Integer.parseInt(keyboard.nextLine());
for (int i = 0; i < t; i++) {
solve();
}
}
public static void solve() {
int n = keyboard.nextInt();
int l = keyboard.nextInt();
int r = keyboard.nextInt();
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= n; i++) {
int max = (l / i) * i;
if (max < l) max += i;
if (max > r) {
System.out.println("NO");
return;
}
sb.append(max).append(" ");
}
System.out.println("YES");
System.out.println(sb.toString().trim());
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 55e8bda57add0746a20bb6b7bbd6399a | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(outputStream);
BDifferenceOfGCDs solver = new BDifferenceOfGCDs();
solver.solve(1, in, out);
out.close();
}
static class BDifferenceOfGCDs {
public void solve(int testNumber, InputReader in, OutputWriter out) {
var tc = in.nextInt();
for (int i = 0; i < tc; i++) {
solution(i, in, out);
}
}
void solution(int testNumber, InputReader in, OutputWriter out) {
int n = in.nextInt();
int l = in.nextInt();
int r = in.nextInt();
EzIntArrayList res = new EzIntArrayList();
for (int i = 1; i <= n; i++) {
if (l >= i) {
if (l % i == 0) {
res.add(l);
} else {
res.add(l + (i - l % i));
}
} else {
// if l is smaller than i, i want the gcd to be i, which means i if possible.
res.add(i);
}
}
for (int i = 0; i < n; i++) {
if (res.get(i) > r) {
out.println("NO");
return;
}
}
out.println("YES");
for (int i = 0; i < n; i++) {
out.print(res.get(i) + " ");
}
out.println();
}
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private InputReader.SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1) {
throw new InputMismatchException();
}
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0) {
return -1;
}
}
return buf[curChar++];
}
public int nextInt() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9') {
throw new InputMismatchException();
}
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public boolean isSpaceChar(int c) {
if (filter != null) {
return filter.isSpaceChar(c);
}
return isWhitespace(c);
}
public static boolean isWhitespace(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
static class OutputWriter {
private final PrintWriter writer;
public OutputWriter(OutputStream outputStream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}
public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}
public void print(Object... objects) {
for (int i = 0; i < objects.length; i++) {
if (i != 0) {
writer.print(' ');
}
writer.print(objects[i]);
}
}
public void println() {
writer.println();
}
public void println(Object... objects) {
print(objects);
writer.println();
}
public void close() {
writer.close();
}
}
static class EzIntArrayList implements EzIntList, EzIntStack {
private static final int DEFAULT_CAPACITY = 10;
private static final double ENLARGE_SCALE = 2.0;
private static final int HASHCODE_INITIAL_VALUE = 0x811c9dc5;
private static final int HASHCODE_MULTIPLIER = 0x01000193;
private int[] array;
private int size;
public EzIntArrayList() {
this(DEFAULT_CAPACITY);
}
public EzIntArrayList(int capacity) {
if (capacity < 0) {
throw new IllegalArgumentException("Capacity must be non-negative");
}
array = new int[capacity];
size = 0;
}
public EzIntArrayList(EzIntCollection collection) {
size = collection.size();
array = new int[size];
int i = 0;
for (EzIntIterator iterator = collection.iterator(); iterator.hasNext(); ) {
array[i++] = iterator.next();
}
}
public EzIntArrayList(int[] srcArray) {
size = srcArray.length;
array = new int[size];
System.arraycopy(srcArray, 0, array, 0, size);
}
public EzIntArrayList(Collection<Integer> javaCollection) {
size = javaCollection.size();
array = new int[size];
int i = 0;
for (int element : javaCollection) {
array[i++] = element;
}
}
public int size() {
return size;
}
public EzIntIterator iterator() {
return new EzIntArrayListIterator();
}
public boolean add(int element) {
if (size == array.length) {
enlarge();
}
array[size++] = element;
return true;
}
public int get(int index) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException("Index " + index + " is out of range, size = " + size);
}
return array[index];
}
private void enlarge() {
int newSize = Math.max(size + 1, (int) (size * ENLARGE_SCALE));
int[] newArray = new int[newSize];
System.arraycopy(array, 0, newArray, 0, size);
array = newArray;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
EzIntArrayList that = (EzIntArrayList) o;
if (size != that.size) {
return false;
}
for (int i = 0; i < size; i++) {
if (array[i] != that.array[i]) {
return false;
}
}
return true;
}
public int hashCode() {
int hash = HASHCODE_INITIAL_VALUE;
for (int i = 0; i < size; i++) {
hash = (hash ^ PrimitiveHashCalculator.getHash(array[i])) * HASHCODE_MULTIPLIER;
}
return hash;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append('[');
for (int i = 0; i < size; i++) {
sb.append(array[i]);
if (i < size - 1) {
sb.append(", ");
}
}
sb.append(']');
return sb.toString();
}
private class EzIntArrayListIterator implements EzIntIterator {
private int curIndex = 0;
public boolean hasNext() {
return curIndex < size;
}
public int next() {
if (curIndex == size) {
throw new NoSuchElementException("Iterator doesn't have more elements");
}
return array[curIndex++];
}
}
}
static interface EzIntStack extends EzIntCollection {
int size();
EzIntIterator iterator();
boolean equals(Object object);
int hashCode();
String toString();
}
static interface EzIntIterator {
boolean hasNext();
int next();
}
static final class PrimitiveHashCalculator {
private PrimitiveHashCalculator() {
}
public static int getHash(int x) {
return x;
}
}
static interface EzIntCollection {
int size();
EzIntIterator iterator();
boolean equals(Object object);
int hashCode();
String toString();
}
static interface EzIntList extends EzIntCollection {
int size();
EzIntIterator iterator();
boolean equals(Object object);
int hashCode();
String toString();
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | 5261c4a76332753c2958f2586ea9cc43 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.io.*;
public class A1{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
static final long mod=1000000007;
public static void Solve() throws IOException{
st=new StringTokenizer(br.readLine());
int n=Integer.parseInt(st.nextToken());
int l=Integer.parseInt(st.nextToken());
int r=Integer.parseInt(st.nextToken());
Map<Integer,Integer> at=new TreeMap<>();
for(int i=n;i>0;i--){
int rem=l%i;
if(l%i!=0) rem=l+i-rem;
else rem=l;
if(rem>=l && rem<=r) at.put(i,rem);
else{
bw.write("NO\n"); return ;
}
}
bw.write("YES\n");
for(int i:at.keySet()) bw.write(at.get(i)+" ");
bw.newLine();
}
/** Main Method**/
public static void main(String[] YDSV) throws IOException{
//int t=1;
int t=Integer.parseInt(br.readLine());
while(t-->0) Solve();
bw.flush();
}
/** Helpers**/
private static char[] getStr()throws IOException{
return br.readLine().toCharArray();
}
private static int Gcd(int a,int b){
if(b==0) return a;
return Gcd(b,a%b);
}
private static long Gcd(long a,long b){
if(b==0) return a;
return Gcd(b,a%b);
}
private static int[] getArrIn(int n) throws IOException{
st=new StringTokenizer(br.readLine());
int[] ar=new int[n];
for(int i=0;i<n;i++) ar[i]=Integer.parseInt(st.nextToken());
return ar;
}
private static Integer[] getArrInP(int n) throws IOException{
st=new StringTokenizer(br.readLine());
Integer[] ar=new Integer[n];
for(int i=0;i<n;i++) ar[i]=Integer.parseInt(st.nextToken());
return ar;
}
private static long[] getArrLo(int n) throws IOException{
st=new StringTokenizer(br.readLine());
long[] ar=new long[n];
for(int i=0;i<n;i++) ar[i]=Long.parseLong(st.nextToken());
return ar;
}
private static List<Integer> getListIn(int n) throws IOException{
st=new StringTokenizer(br.readLine());
List<Integer> al=new ArrayList<>();
for(int i=0;i<n;i++) al.add(Integer.parseInt(st.nextToken()));
return al;
}
private static List<Long> getListLo(int n) throws IOException{
st=new StringTokenizer(br.readLine());
List<Long> al=new ArrayList<>();
for(int i=0;i<n;i++) al.add(Long.parseLong(st.nextToken()));
return al;
}
private static long pow_mod(long a,long b) {
long result=1;
while(b!=0){
if((b&1)!=0) result=(result*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return result;
}
private static int lower_bound(int a[],int x){
int l=-1,r=a.length;
while(l+1<r){
int m=(l+r)>>>1;
if(a[m]>=x) r=m;
else l=m;
}
return r+1;
}
private static long lower_bound(long a[],long x){
int l=-1,r=a.length;
while(l+1<r){
int m=(l+r)>>>1;
if(a[m]>=x) r=m;
else l=m;
}
return r+1;
}
private static int upper_bound(int a[],int x){
int l=-1,r=a.length;
while(l+1<r){
int m=(l+r)>>>1;
if(a[m]<=x) l=m;
else r=m;
}
return l+1;
}
private static long upper_bound(long a[],long x){
int l=-1,r=a.length;
while(l+1<r){
int m=(l+r)>>>1;
if(a[m]<=x) l=m;
else r=m;
}
return l+1;
}
private static boolean Sqrt(int x){
int a=(int)Math.sqrt(x);
return a*a==x;
}
private static boolean Sqrt(long x){
long a=(long)Math.sqrt(x);
return a*a==x;
}
} | Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | bb1e05d4ad80d276188d9014f2596128 | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class ok {
static int t, l, n, r;
static int[] a = new int[100001];
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
t = cin.nextInt();
while (t-- > 0) {
n = cin.nextInt();
l = cin.nextInt();
r = cin.nextInt();
boolean ocei = true;
for (int i = 1; i <= n && ocei; ++i) {
a[i] = ((l - 1) / i + 1) * i;
ocei = a[i] <= r;
}
if (ocei) {
System.out.println("yes");
for (int i = 1; i <= n; ++i)
System.out.printf("%d ", a[i]);
System.out.print('\n');
continue;
}
System.out.println("No");
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output | |
PASSED | f51e492d5d747f4b0ad79e750ceaac5e | train_108.jsonl | 1657982100 | You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\dots,a_n$$$ ($$$l\le a_i\le r$$$) such that $$$\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$. | 256 megabytes | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.util.*;
public class Main
{
public static boolean issorted(int []arr){
for(int i = 1;i<arr.length;i++){
if(arr[i]<arr[i-1]){
return false;
}
}
return true;
}
public static long sum(int []arr){
long sum = 0;
for(int i = 0;i<arr.length;i++){
sum+=arr[i];
}
return sum;
}
public static class pair implements Comparable<pair>{
int x;
int y;
pair(int x,int y){
this.x = x;
this.y = y;
}
public int compareTo(pair o){
return this.x - o.x; // sort increasingly on the basis of x
// return o.x - this.x // sort decreasingly on the basis of x
}
}
public static void swap(int []arr,int i,int j){
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
public static int gcd(int a, int b){
if (b == 0)
return a;
return gcd(b, a % b);
}
static int []parent = new int[1000];
static int []size = new int[1000];
public static void make(int v){
parent[v] = v;
size[v] = 1;
}
public static int find(int v){
if(parent[v]==v){
return v;
}
else{
return parent[v] = find(parent[v]);
}
}
public static void union(int a,int b){
a = find(a);
b = find(b);
if(a!=b){
if(size[a]>size[b]){
parent[b] = parent[a];
size[b]+=size[a];
}
else{
parent[a] = parent[b];
size[a]+=size[b];
}
}
}
static boolean []visited = new boolean[1000];
public static void dfs(int vertex,ArrayList<ArrayList<Integer>>graph){
if(visited[vertex] == true){
return;
}
System.out.println(vertex);
for(int child : graph.get(vertex)){
// work to be done before entering the child
dfs(child,graph);
// work to be done after exitting the child
}
}
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while(t-->0){
boolean flag = true;
int n = scn.nextInt();
int l = scn.nextInt();
int r = scn.nextInt();
int []arr = new int[n+1];
for(int i = n;i>=1;i--){
int val = r%i;
if((r - val)>=l){
arr[n-i] = r-val;
// System.out.print(arr[n-i]+ " ");
}
else{
flag = false;
}
}
if(flag){
System.out.println("YES");
for(int i = n-1;i>=0;i--){
System.out.print(arr[i]+" ");
}
System.out.println();
}
else{
System.out.println("NO");
}
}
}
}
| Java | ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"] | 1 second | ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"] | NoteIn the first test case, $$$\gcd(1,a_1),\gcd(2,a_2),\ldots,\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively. | Java 17 | standard input | [
"constructive algorithms",
"math"
] | d2cc6efe7173a64482659ba59efeec16 | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \le n \le 10^5$$$, $$$1\le l\le r\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | 1,100 | For each test case, if there is no solution, print "NO" (without quotes). You can print letters in any case (upper or lower). Otherwise, print "YES" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ — the array you construct. If there are multiple solutions, you may output any. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.