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
bf815272850aa9d4835bb9778f6cc97e
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.sql.SQLOutput; import java.util.*; import static java.lang.Math.min; import static java.lang.Math.max; import static java.lang.Math.abs; import static java.lang.Math.sqrt; public class Main { private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { int t = getSingle(); while(t --> 0) { StringTokenizer st = new StringTokenizer(br.readLine()); int n = getNextInt(st); int l = getNextInt(st); int r = getNextInt(st); 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 { System.out.println("NO"); break; } } if(arr[n-1] != 0) { System.out.println("YES"); for(int v : arr) { System.out.print(v + " "); } System.out.println(); } } } public static int[] getInts(int n, BufferedReader br, StringTokenizer st) { int[] arr = new int[n]; for(int i=0; i < n; ++i) { arr[i] = Integer.parseInt(st.nextToken()); } return arr; } public static void printArr(int[] a) { for(int i : a) { System.out.print(i + " "); } System.out.println(); } public static void sort(int[] a) { ArrayList<Integer> ls = new ArrayList<Integer>(); for (int x : a) { ls.add(x); } Collections.sort(ls); for (int i = 0; i < a.length; i++) { a[i] = ls.get(i); } } public static long pow(long x, long y, long p) { long res = 1L; x = x%p; while(y > 0) { if((y&1)==1) res = (res*x)%p; y >>= 1; x = (x*x)%p; } return res; } public static long getSingleLong() throws IOException { return Long.parseLong(br.readLine()); } public static int getSingle() throws IOException { return Integer.parseInt(br.readLine()); } public static int getNextInt(StringTokenizer st) { return Integer.parseInt(st.nextToken()); } }
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
dd62e7c0c8161b200f8809fb0a4c859a
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
PASSED
e2087733932a58b98520f521c0a3f3ae
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.HashMap; //import java.util.StringTokenizer; import java.io.*; import java.util.*; 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; } } // for(int i=0;i<n;i++) arr[i] = fr.nextInt(); // for(int i=0;i<n;i++) { // if(map.containsKey(arr[i])) { // int freq = map.get(arr[i]); // freq++; // map.put(arr[i],freq); // } // else map.put(arr[i],1); // } public static void main(String[] args) { FastReader fr = new FastReader(); // System.out.println("Enter t : "); int t = fr.nextInt(); while(t-->0) { int n = fr.nextInt(); int l = fr.nextInt(); int r = fr.nextInt(); boolean flag = true; if(n==1) { System.out.println("YES"); System.out.println(l); } else { ArrayList<Integer> ans = new ArrayList<>(); for(int i=1;i<=n;i++) { int x = l%i; if(x==0) ans.add(l); else if(l+i-x>=l && l+i-x<=r) ans.add(l+i-x); else { flag = false; break; } } if(!flag) System.out.println("NO"); else { System.out.println("YES"); for(int p=0;p<ans.size();p++) System.out.print(ans.get(p) + " "); 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
506c03b9379225738a27e1dd403f940d
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 static java.lang.Math.*; import static java.lang.System.*; public class DifferenceOfGCDs implements Runnable { final String[] result = {"YES", "NO"}; private final void solution() throws IOException { // InputReader input = new InputReader(new FileReader(System.getenv("INPUT"))); // PrintWriter output = new PrintWriter(new BufferedOutputStream(new FileOutputStream(System.getenv("OUTPUT")))); InputReader input = new InputReader(in); PrintWriter output = new PrintWriter(new BufferedOutputStream(out)); short test = input.nextShort(); while (test-- > 0) { int n = input.nextInt(); long l = input.nextLong(), r = input.nextLong(); int idx = 0; long[] arr = new long[n]; for (int i = 1; i <= n; i++) { long low = l / i, high = r / i; low *= i; high *= i; if (high < l || low > r) { idx = 1; break; } else { arr[i - 1] = high; } } output.println(result[idx]); if (idx == 0) printArr(output, arr); } output.close(); input.close(); } private final long gcd(long a, long b) { return a % b == 0 ? b : gcd(b, a%b); } @Override public void run() { try { solution(); } catch (IOException ignore) {} } public static void main(String... args) throws IOException { new Thread(null, new DifferenceOfGCDs(), "Main", 1 << 26).start(); } private static final void printArr(PrintWriter output, int...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private static final void printArr(PrintWriter output, double...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private static final void printArr(PrintWriter output, long...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private static final void printArr(PrintWriter output, String...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private static final boolean isPowerofTwo(long n){ if (n <= 0) return false; int bit = (int) (Math.log(n) / Math.log(2)); long expec = 1 << bit; return n % expec == 0; } } class InputReader { private StringTokenizer st; private BufferedReader br; public InputReader(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public InputReader(FileReader s) throws FileNotFoundException { br = new BufferedReader(s); } public final String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public final String nextLine() throws IOException { return br.readLine(); } public final byte nextByte() throws IOException { return Byte.parseByte(next()); } public final short nextShort() throws IOException { return Short.parseShort(next()); } public final int nextInt() throws IOException { return Integer.parseInt(next()); } public final long nextLong() throws IOException { return Long.parseLong(next()); } public final double nextDouble() throws IOException { return Double.parseDouble(next()); } public final char nextChar() throws IOException { return next().charAt(0); } public final boolean nextBoolean() throws IOException { return Boolean.parseBoolean(next()); // return Boolean.getBoolean(next()); // return Boolean.valueOf(next()); } public int[] readIntArray(int n) throws IOException { int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = nextInt(); return arr; } public int[] readIntArray() throws IOException { return java.util.Arrays.stream(nextLine().split("\\s+")). mapToInt(Integer::parseInt).toArray(); } public long[] readLongArray(int n) throws IOException { long[] arr = new long[n]; for (int i = 0; i < n; i++) arr[i] = nextLong(); return arr; } public long[] readLongArray() throws IOException { return java.util.Arrays.stream(nextLine().split("\\s+")). mapToLong(Long::parseLong).toArray(); } public double[] readDoubleArray(int n) throws IOException { double[] arr = new double[n]; for (int i = 0; i < n; i++) arr[i] = nextDouble(); return arr; } public double[] readDoubleArray() throws IOException { return java.util.Arrays.stream(nextLine().split("\\s+")). mapToDouble(Double::parseDouble).toArray(); } public String[] readStringArray(int n) throws IOException { String[] arr = new String[n]; for (int i = 0; i < n; i++) arr[i] = next(); return arr; } public String[] readStringArray() throws IOException { return nextLine().split("\\s+"); } public boolean ready() throws IOException { return br.ready(); } public void close() throws IOException { br.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
cbb671df48cd98dc9271638bfa280420
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 codeforces_2022_07_16_B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); for (int numCases = scanner.nextInt(); numCases > 0; --numCases) { int n = scanner.nextInt(), l = scanner.nextInt(), r = scanner.nextInt(); int[] ans = new int[n]; boolean doable = true; for (int i = 1; i <= n; i++) { if (r - (r % i) < l) { doable = false; break; } else { ans[i - 1] = r - (r % i); } } if (!doable) { System.out.println("NO"); } else { System.out.println("YES"); for (int a : ans) { System.out.print(String.format("%d ", a)); } System.out.println(); } } scanner.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
42ec897995a297a3b53da27b6665ccfb
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.io.Writer; import java.io.OutputStreamWriter; import java.io.IOException; 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(); int testCount = Integer.parseInt(in.next()); for (int i = 1; i <= testCount; i++) { solver.solve(i, in, out); } out.close(); } static class BDifferenceOfGCDs { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(); long l = in.nextInt(); long r = in.nextInt(); long[] a = new long[n + 1]; for (int i = 1; i <= n; i++) { a[i] = (l + i - 1) / i * i; if (a[i] > r) { out.println("NO"); return; } } out.println("YES"); for (int i = 1; i <= n; i++) { out.print(a[i], ""); } out.println(); } } 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 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 UnknownError(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new UnknownError(); } 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 UnknownError(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public String nextString() { int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { if (Character.isValidCodePoint(c)) { res.appendCodePoint(c); } c = read(); } while (!isSpaceChar(c)); return res.toString(); } 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 String next() { return nextString(); } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
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
300047fa7953881a8b37f38d66b80206
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 Codechef {static long mod=(long)1e9+7; static class pair{ int first;int second;pair(int first,int second){this.first=first;this.second=second;}} static class Reader { BufferedReader in;StringTokenizer st; public Reader() {in = new BufferedReader(new InputStreamReader(System.in));st = new StringTokenizer("");} public String nextLine() throws IOException {st = new StringTokenizer("");return in.readLine();} public String next() throws IOException {while (!st.hasMoreTokens()) {st = new StringTokenizer(in.readLine());}return st.nextToken();} public int nextInt() throws IOException {return Integer.parseInt(next());} public long nextLong() throws IOException {return Long.parseLong(next());} public double nextDouble() throws IOException {return Double.parseDouble(next());}} static Reader in = new Reader();static PrintWriter out = new PrintWriter(System.out); static class TreeMultiset<T> {TreeMap<T,Integer> h; public TreeMultiset() {h = new TreeMap<>();}private boolean has(T key) {return h.containsKey(key);} private void add(T key) {h.put(key,h.getOrDefault(key,0)+1);}private int get(T key) {return h.get(key);} public void del(T key) {if(h.containsKey(key)) {if(h.get(key)==1) h.remove(key);else h.put(key,h.getOrDefault(key,0)-1);}} private T down(T key) { Map.Entry<T, Integer> val;val=h.floorEntry(key);if(val!=null) {return val.getKey();}return null;} public T up(T key) { Map.Entry<T, Integer> val;val=h.ceilingEntry(key);if(val!=null) {return val.getKey();}return null;} public int size(){int s=0;for(int k:h.values()) s+=k;return s;}} //-----------------------------INPUT-------------------------------------------------// public static int ni() throws IOException {return in.nextInt();} public static long nl() throws IOException {return in.nextLong();} public static String rl() throws IOException {return in.next();} public static char nc() throws IOException {return in.next().charAt(0);} //----------------------------ARRAYS INPUT--------------------------------------------// public static int[] ai(long n) throws IOException {int[] arr = new int[(int)n];for (int i = 0; i < n; i++) {arr[i] = in.nextInt();}return arr;} public static long[] al(long n) throws IOException {long[] arr = new long[(int)n];for (int i = 0; i < n; i++) {arr[i] = in.nextLong();}return arr;} public static char[] ac() throws IOException {String s = in.next();return s.toCharArray();} public static int[] ac(int n) throws IOException {String s = in.next();int[] arr =new int[n];for(int i=0;i<n;i++) arr[i]=s.charAt(i)-'0';return arr;} //----------------------------Print---------------------------------------------------// public static void pt(int[] arr) {for (int j : arr) out.print(j + " ");out.println();} public static void pt(long[] arr) {for (long l : arr) out.print(l + " ");out.println();} public static void pt(char[] arr) {for (char l : arr) out.print(l );out.println();} //--------------------------------------------Other Functions----------------------------------------------------// public static double nRoot(double x,double y){double a=1,b=x;double mid=b;while(b-a>0.000001) {mid=(a+b)/2;float p=1;for(int i=0;i<y;i++) {p*=mid;}if(p<x) a=mid;else b=mid;}return mid;} public static long gcd(long a, long b) {BigInteger x = BigInteger.valueOf(a).gcd(BigInteger.valueOf(b));return Long.parseLong(String.valueOf(x));} public static long expo(long a, long b) {long res = 1;while (b > 0) {if ((b & 1) != 0) res = res * a;a = a * a;b >>= 1;}return res;} public static long modexp(long a, long b) {long res = 1;while (b > 0) {if ((b & 1) != 0) res = (res * a % mod) % mod;a = (a % mod * a % mod) % mod;b >>= 1;}return res % mod;} public static int[] permute(int n) {int[] arr = new int[n];for (int i = 0; i < n; i++) {arr[i] = i+1;}return arr;} public static long min(long[] arr) {long min = Long.MAX_VALUE;for (long l : arr) {if (l < min) min = l;}return min;} public static long max(long[] arr) {long max = Long.MIN_VALUE;for (long l : arr) {if (l > max) max = l;}return max;} public static int max(int[] arr) {int max = Integer.MIN_VALUE;for (int l : arr) {if (l > max) max = l;}return max;} public static void sort(long[] arr) {List<Long> list = new ArrayList<>();for (long i : arr) {list.add(i);}Collections.sort(list);for (int i = 0; i < arr.length; i++) {arr[i] = list.get(i);}} public static void sort(int[] arr) {List<Integer> list = new ArrayList<>();for (int i : arr) {list.add(i);}Collections.sort(list);for (int i = 0; i < arr.length; i++) {arr[i] = list.get(i);}} public static long countfactors(long n) {long ans = 0;for (long i = 1; i * i <= n; i++) {if (n % i == 0) {ans += 2;if (n / i == i) ans--;}}return ans;} public static boolean isprime(long n) {for (long i = 2; i * i <= n; i++) {if (n % i == 0) return false;}return true;} public static int [] copy(int[] arr) {int []brr=new int[arr.length];System.arraycopy(arr, 0, brr, 0, arr.length);return brr;} public static long [] copy(long[] arr) {long []brr=new long[arr.length];System.arraycopy(arr, 0, brr, 0, arr.length);return brr;} public static long countDigit(long n) {long count = 0;while (n != 0) {n = n / 10;++count;}return count;} public static List<pair> sortpair(int[] n, int[] h) {List<pair> A=new ArrayList<pair>();for(int i=0;i<n.length;i++){A.add(new pair(h[i],n[i]));}A.sort(Comparator.comparingInt(a -> a.first));return A;} public static long sum(long []arr) {long s=0;for(long i:arr) s+=i;return s;} public static long kadane(long a[]) {long max_so_far=Long.MIN_VALUE, max_ending_here=0;for (long l : a) {max_ending_here = max_ending_here + l;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 long lower(long a) {long l=(long)Math.floor(Math.sqrt(a));return l*l;} public static long upper(long a) {long l=(long)Math.ceil(Math.sqrt(a));return l*l;} public static boolean isSorted(int []arr){int n=arr.length;for(int i=0;i<n-1;i++){if(arr[i]>arr[i+1])return false;} return true;} public static boolean isSorted(long []arr){int n=arr.length;for(int i=0;i<n-1;i++){if(arr[i]>arr[i+1])return false;} return true;} static int msbNumber(int n) {return (int)(Math.log(n) / Math.log(2));} static int msbNumber(long n) {return (int)(Math.log(n) / Math.log(2));} //---------------------------------------------------------------------------------------------------------------------------------------// public static void Khud_Bhi_Krle_Kuch() throws IOException { int n=ni(); // int up=(int)upper(n-1); // int i=(int)n-1; long l=nl(); long r=nl(); long arr[]=new long[n]; for(int i=1;i<=n;i++) { if(l%i==0) { arr[i-1]=l; } else { long rem=l%i; if(i-rem+l>r) { out.println("NO"); return; } arr[i-1]=l+i-rem; } } out.println("YES"); pt(arr); } //--------------------------------------MAIN--------------------------------------------// public static void main(String[] args) throws Exception {int t=ni();while(t--!=0) Khud_Bhi_Krle_Kuch();out.close();}} // public static void main(String[] args) throws Exception {Khud_Bhi_Krle_Kuch();out.close();}} //ela-sorting // int n=ni();long[] arr =al(n); // HashMap<Integer,int[]>h=new HashMap<>(); // int[] bit =new int[33]; // if(arr[0]!=0) { // int c = setBitNumber(arr[0])+1; // bit[c]++; // } // else // bit[0]++; // h.put(0,bit); // for(int i=1;i<n;i++) { // int []bits; // bit=h.get(i-1); // bits=copy(bit); // long a=arr[i]; // if(arr[i]!=0) { // int c = setBitNumber(a)+1; // bits[c]++; // } // else // bits[0]++; // h.put(i,bits); // } // int q=ni(); // while(q--!=0) { // int l=ni()-1,r=ni()-1; // long x=ni(); // if(x==0) // { // out.println(r-l+1); // continue; // } // int c=setBitNumber(x); // int[] ra =h.get(r),la =h.get(l); // for(int i=0;i<32;i++) // ra[i]-=la[i]; // long a=arr[l]; // int ct=0; // ct=setBitNumber(a); // ra[ct]++; // int ans=0; // for(int i=0;i<32;i++) { // if(i!=c) { // ans+=ra[i]; // } // } // out.println(ans); // } //// out.println(setBitNumber(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 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
db596003058c05f11143279e20517f6e
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.util.spi.AbstractResourceBundleProvider; public class codeforces { 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(); boolean flag =true; ArrayList<Integer>list = new ArrayList<>(); int x=0; for(int i=1;i<=n;i++){ x = (((l - 1) / i) + 1) * i; if(x>r){ flag=false; System.out.println("NO"); break; }else{ list.add(x); } } if(flag){ System.out.println("YES"); for(int i=0;i<n;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 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
142eac3f28c966c32d4f62e632ef8aa0
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 problemB { public static void main(String[] args) { Scanner sh = new Scanner(System.in); int t = sh.nextInt(); while(t>0){ int n = sh.nextInt(); int l = sh.nextInt(); int r = sh.nextInt(); int a[] = new int[n+1]; boolean check = true; for(int i = 1; i<=n; i++){ int temp = r/i; temp = temp*i; if(temp<l){ check = false; break; }else{ a[i] = temp; } } if(check){ System.out.println("YES"); for(int i = 1; i<=n; i++){ System.out.print(a[i]+" "); } System.out.println(); }else{ System.out.println("NO"); } 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 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
635840396dc8765fae3f57cd37297e12
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) throws Exception { Scanner scan = new Scanner(System.in); StringBuilder str = new StringBuilder(); int tc = scan.nextInt(); while (tc-->0) { int n = scan.nextInt(); int l = scan.nextInt(); int r = scan.nextInt(); int[] ans = new int[n+1]; int i = 1; for (; i < ans.length; i++) { int num = (r - r % i); if (num < l) break; ans[i] = num; } if (i != n+1) { str.append("NO\n"); } else { str.append("YES\n"); for (i = 1; i < ans.length; i++) str.append(ans[i] + " "); str.append("\n"); } } System.out.println(str.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
4f9ed6b1e467b74a9f803ec39b5ff012
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 text1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int cs = sc.nextInt(); for(int dz = 0;dz < cs;dz ++) { int length = sc.nextInt(); long[] number = new long[length]; long left = sc.nextLong(), right = sc.nextLong(); boolean pd = true; for(int dz1 = 1;dz1 <= length;dz1 ++){ if(left % dz1 == 0) number[dz1 - 1] = left; else if(dz1 - (left % dz1) <= right - left) number[dz1 - 1] = left + dz1 - (left % dz1); else if(dz1 - (left % dz1) > right - left) pd = false; } if(!pd) System.out.println("NO"); else{ System.out.println("YES"); for(int dz1 = 0;dz1 < length;dz1 ++) System.out.print(number[dz1] + " "); System.out.println(); } } return ; } }
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
ad872deef6fdc9511d49f3155904c70a
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.algorithms; import java.util.*; public class Pset7 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int length = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); boolean valid = true; int[] arr = new int[length+1]; for (int i = 1; i <= length; i++) { arr[i] = ((l-1) / i + 1) * i; valid = valid && arr[i] <= r; } if (valid) { System.out.println("YES"); for (int i = 1; i <= length; 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
PASSED
6ec930a8d59f37f4cc6489dcaa8d5cb5
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 CP; import java.util.*; import java.util.Arrays; import java.util.Collections; import java.util.Dictionary; import java.util.HashMap; import java.util.Hashtable; import java.util.PriorityQueue; public class Main{ public static int gcd(int v1 , int v2) { int rv = 0; while(v1 % v2 != 0) { int rem = v1 % v2; v1 = v2; v2 = rem; } rv = v2; return rv; } public static void main(String args[]) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); for(int t = 1;t <= tc;t++) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[] ans = new int[n]; int flag = 1; for(int i = 1;i <= n;i++) { ans[i - 1] = (((l - 1) / i) + 1) * i; if(ans[i - 1] > r) { flag = 0; break; } } if(flag == 1) { System.out.println("YES"); for(int i = 0;i < ans.length;i++) { System.out.print(ans[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
PASSED
8f8594ade33130f00d4900e98558863d
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.time.*; import static java.lang.Math.*; @SuppressWarnings("unused") public class B { static boolean DEBUG = false; static int query = 0; static Reader fs; static PrintWriter pw; static void solve() { int n = fs.nextInt(); int l = fs.nextInt(); int r = fs.nextInt(); int a[] = new int[n+1]; for(int i = 1 ; i <= n ; i++) { int k = l/i + (l%i == 0 ? 0 : 1); if(i * k > r) { pw.println("NO");return; } a[i] = i * k; } pw.println("YES"); for(int i = 1 ; i <= n ; i++) { pw.print(a[i] + " "); } pw.println(); } static int __gcd(int a, int b) { return b == 0 ? a : __gcd(b, a%b); } public static void main(String[] args) { Instant start = Instant.now(); fs = new Reader(); pw = new PrintWriter(System.out); int t = fs.nextInt(); while(t-- > 0) solve(); Instant end = Instant.now(); if (DEBUG) { pw.println(Duration.between(start, end)); } pw.close(); } static void sort(int a[]) { ArrayList<Integer> l = new ArrayList<Integer>(); for (int x : a) l.add(x); Collections.sort(l); for (int i = 0; i < a.length; i++) { a[i] = l.get(i); } } public static void print(long a, long b, long c, PrintWriter pw) { pw.println(a + " " + b + " " + c); return; } static class Reader { BufferedReader br; StringTokenizer st; public Reader() { 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[] readArray(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } int[][] read2Array(int n, int m) { int a[][] = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = nextInt(); } } 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 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
6a52541e47d12f0d52901baebd5fe8fc
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.ArrayList; import java.util.Scanner; public class Srhossain{ public static void main(String[] args){ new Srhossain(); } public Srhossain(){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int tc=1; tc<=t; tc++){ int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[] arr = new int[n]; for(int i=1; i<=n; i++){ arr[i-1] = r - r%i; if(arr[i-1] < l){ n = -1; break; } } if(n == -1)showln("NO"); else{ showln("YES"); for(int x: arr){ show(x+" "); } showln(""); } } sc.close(); } public void showarr(int[] arr){ for(int i=0; i<arr.length; i++) System.out.print(arr[i]+" "); showln(""); } public void show(String s){ System.out.print(s); } public void showln(String s){ System.out.println(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 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
a2005935beaa9276e08c5858e21331fa
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.text.*; import java.util.*; /** * Provide prove of correctness before implementation. Implementation can cost a lot of time. * Anti test that prove that it's wrong. * <p> * Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write more informative names to simulation * <p> * Will program ever exceed limit? * Try all approaches with prove of correctness if task is not obvious. * If you are given formula/rule: Try to play with it. * Analytic solution/Hardcoded solution/Constructive/Greedy/DP/Math/Brute force/Symmetric data * Number theory * Game theory (optimal play) that consider local and global strategy. * Start writing the hardest code first */ public class B { final boolean ONLINE_JUDGE = java.lang.System.getProperty("ONLINE_JUDGE") != null; final boolean ANTI_TEST_FINDER_MODE = false; final Random random = new Random(42); private int solveOne(int testCase) { int n = nextInt(); int l = nextInt(); int r = nextInt(); int[] ans = new int[n]; for(int i = 0; i < n; i++){ int ok = (r / (i + 1)) * (i + 1); if(l <= ok) { ans[i] = ok; } else { System.out.println("NO"); return 0; } } System.out.println("YES"); for (int i = 0; i < n; i++) { System.out.print(ans[i]).print(' '); } System.out.println(); return 0; } private int solveOneNaive(int testCase) { return 0; } private void solve() { if (ANTI_TEST_FINDER_MODE) { int t = 100_000; for (int testCase = 0; testCase < t; testCase++) { int expected = solveOneNaive(testCase); int actual = solveOne(testCase); if (expected != actual) { throw new AssertionRuntimeException( this.getClass().getSimpleName(), testCase, expected, actual); } } } else { int t = nextInt(); for (int testCase = 0; testCase < t; testCase++) { solveOne(testCase); } } } class AssertionRuntimeException extends RuntimeException { AssertionRuntimeException(String testName, int testCase, Object expected, Object actual, Object... input) { super("Testcase: " + testCase + "\n expected = " + expected + ",\n actual = " + actual + ",\n " + Arrays.deepToString(input)); } } private void assertThat(boolean b) { if (!b) throw new RuntimeException(); } private void assertThat(boolean b, String s) { if (!b) throw new RuntimeException(s); } private int assertThatInt(long a) { assertThat(Integer.MIN_VALUE <= a && a <= Integer.MAX_VALUE, "Integer overflow long = [" + a + "]" + " int = [" + (int) a + "]"); return (int) a; } void _______debug(String str, Object... os) { if (!ONLINE_JUDGE) { System.out.println(MessageFormat.format(str, os)); System.out.flush(); } } void _______debug(Object o) { if (!ONLINE_JUDGE) { _______debug("{0}", String.valueOf(o)); } } private int nextInt() { return System.in.readInt(); } private long nextLong() { return System.in.readLong(); } private String nextString() { return System.in.readString(); } private int[] nextIntArr(int n) { return System.in.readIntArray(n); } private long[] nextLongArr(int n) { return System.in.readLongArray(n); } public static void main(String[] args) { new B().run(); } static class System { private static FastInputStream in; private static FastPrintStream out; } private void run() { // final long startTime = java.lang.System.currentTimeMillis(); final boolean USE_IO = ONLINE_JUDGE; if (USE_IO) { System.in = new FastInputStream(java.lang.System.in); System.out = new FastPrintStream(java.lang.System.out); solve(); System.out.flush(); } else { final String nameIn = "input.txt"; final String nameOut = "output.txt"; try { System.in = new FastInputStream(new FileInputStream(nameIn)); System.out = new FastPrintStream(new PrintStream(nameOut)); solve(); System.out.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } } // final long endTime = java.lang.System.currentTimeMillis(); // _______debug("Execution time: {0}", endTime - startTime); } private static class FastPrintStream { private static final int BUF_SIZE = 8192; private final byte[] buf = new byte[BUF_SIZE]; private final OutputStream out; private int ptr = 0; private FastPrintStream() { this(java.lang.System.out); } public FastPrintStream(OutputStream os) { this.out = os; } public FastPrintStream(String path) { try { this.out = new FileOutputStream(path); } catch (FileNotFoundException e) { throw new RuntimeException("FastWriter"); } } public FastPrintStream print(byte b) { buf[ptr++] = b; if (ptr == BUF_SIZE) innerFlush(); return this; } public FastPrintStream print(char c) { return print((byte) c); } public FastPrintStream print(char[] s) { for (char c : s) { buf[ptr++] = (byte) c; if (ptr == BUF_SIZE) innerFlush(); } return this; } public FastPrintStream print(String s) { s.chars().forEach(c -> { buf[ptr++] = (byte) c; if (ptr == BUF_SIZE) innerFlush(); }); return this; } //can be optimized public FastPrintStream print0(char[] s) { if (ptr + s.length < BUF_SIZE) { for (char c : s) { buf[ptr++] = (byte) c; } } else { for (char c : s) { buf[ptr++] = (byte) c; if (ptr == BUF_SIZE) innerFlush(); } } return this; } //can be optimized public FastPrintStream print0(String s) { if (ptr + s.length() < BUF_SIZE) { for (int i = 0; i < s.length(); i++) { buf[ptr++] = (byte) s.charAt(i); } } else { for (int i = 0; i < s.length(); i++) { buf[ptr++] = (byte) s.charAt(i); if (ptr == BUF_SIZE) innerFlush(); } } return this; } private static int countDigits(int l) { if (l >= 1000000000) return 10; if (l >= 100000000) return 9; if (l >= 10000000) return 8; if (l >= 1000000) return 7; if (l >= 100000) return 6; if (l >= 10000) return 5; if (l >= 1000) return 4; if (l >= 100) return 3; if (l >= 10) return 2; return 1; } public FastPrintStream print(int x) { if (x == Integer.MIN_VALUE) { return print((long) x); } if (ptr + 12 >= BUF_SIZE) innerFlush(); if (x < 0) { print((byte) '-'); x = -x; } int d = countDigits(x); for (int i = ptr + d - 1; i >= ptr; i--) { buf[i] = (byte) ('0' + x % 10); x /= 10; } ptr += d; return this; } private static int countDigits(long l) { if (l >= 1000000000000000000L) return 19; if (l >= 100000000000000000L) return 18; if (l >= 10000000000000000L) return 17; if (l >= 1000000000000000L) return 16; if (l >= 100000000000000L) return 15; if (l >= 10000000000000L) return 14; if (l >= 1000000000000L) return 13; if (l >= 100000000000L) return 12; if (l >= 10000000000L) return 11; if (l >= 1000000000L) return 10; if (l >= 100000000L) return 9; if (l >= 10000000L) return 8; if (l >= 1000000L) return 7; if (l >= 100000L) return 6; if (l >= 10000L) return 5; if (l >= 1000L) return 4; if (l >= 100L) return 3; if (l >= 10L) return 2; return 1; } public FastPrintStream print(long x) { if (x == Long.MIN_VALUE) { return print("" + x); } if (ptr + 21 >= BUF_SIZE) innerFlush(); if (x < 0) { print((byte) '-'); x = -x; } int d = countDigits(x); for (int i = ptr + d - 1; i >= ptr; i--) { buf[i] = (byte) ('0' + x % 10); x /= 10; } ptr += d; return this; } public FastPrintStream print(double x, int precision) { if (x < 0) { print('-'); x = -x; } x += Math.pow(10, -precision) / 2; print((long) x).print("."); x -= (long) x; for (int i = 0; i < precision; i++) { x *= 10; print((char) ('0' + (int) x)); x -= (int) x; } return this; } public FastPrintStream println(char c) { return print(c).println(); } public FastPrintStream println(int x) { return print(x).println(); } public FastPrintStream println(long x) { return print(x).println(); } public FastPrintStream println(String x) { return print(x).println(); } public FastPrintStream println(Object x) { return print(x.toString()).println(); } public FastPrintStream println(double x, int precision) { return print(x, precision).println(); } public FastPrintStream println() { return print((byte) '\n'); } public FastPrintStream printf(String format, Object... args) { return print(String.format(format, args)); } private void innerFlush() { try { out.write(buf, 0, ptr); ptr = 0; } catch (IOException e) { throw new RuntimeException("innerFlush"); } } public void flush() { innerFlush(); try { out.flush(); } catch (IOException e) { throw new RuntimeException("flush"); } } } private static class FastInputStream { private boolean finished = false; private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; public FastInputStream(InputStream stream) { this.stream = stream; } public double[] readDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = readDouble(); } return array; } public String[] readStringArray(int size) { String[] array = new String[size]; for (int i = 0; i < size; i++) { array[i] = readString(); } return array; } public char[] readCharArray(int size) { char[] array = new char[size]; for (int i = 0; i < size; i++) { array[i] = readCharacter(); } return array; } public String readText() { StringBuilder result = new StringBuilder(); while (true) { int character = read(); if (character == '\r') { continue; } if (character == -1) { break; } result.append((char) character); } return result.toString(); } public long[] readLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = readLong(); } return array; } public int[] readIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = readInt(); } return array; } 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 peek() { if (numChars == -1) { return -1; } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { return -1; } if (numChars <= 0) { return -1; } } return buf[curChar]; } public int peekNonWhitespace() { while (isWhitespace(peek())) { read(); } return peek(); } public int readInt() { 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 long readLong() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long 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 readString() { int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { if (Character.isValidCodePoint(c)) { res.appendCodePoint(c); } c = read(); } while (!isSpaceChar(c)); return res.toString(); } public char[] readStringAsCharArray() { int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { if (Character.isValidCodePoint(c)) { res.appendCodePoint(c); } c = read(); } while (!isSpaceChar(c)); char[] resArr = new char[res.length()]; res.getChars(0, res.length(), resArr, 0); return resArr; } 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; } private String readLine0() { StringBuilder buf = new StringBuilder(); int c = read(); while (c != '\n' && c != -1) { if (c != '\r') { buf.appendCodePoint(c); } c = read(); } return buf.toString(); } public String readLine() { String s = readLine0(); while (s.trim().length() == 0) { s = readLine0(); } return s; } public String readLine(boolean ignoreEmptyLines) { if (ignoreEmptyLines) { return readLine(); } else { return readLine0(); } } public char readCharacter() { int c = read(); while (isSpaceChar(c)) { c = read(); } return (char) c; } public double readDouble() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } double res = 0; while (!isSpaceChar(c) && c != '.') { if (c == 'e' || c == 'E') { return res * Math.pow(10, readInt()); } if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } if (c == '.') { c = read(); double m = 1; while (!isSpaceChar(c)) { if (c == 'e' || c == 'E') { return res * Math.pow(10, readInt()); } if (c < '0' || c > '9') { throw new InputMismatchException(); } m /= 10; res += (c - '0') * m; c = read(); } } return res * sgn; } public boolean isExhausted() { int value; while (isSpaceChar(value = peek()) && value != -1) { read(); } return value == -1; } public String next() { return readString(); } public SpaceCharFilter getFilter() { return filter; } public void setFilter(SpaceCharFilter filter) { this.filter = filter; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
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
91e3104fc6849d82abbfa9ce78187fc0
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 javax.print.attribute.IntegerSyntax; import java.awt.image.AreaAveragingScaleFilter; import java.util.*; import java.io.*; import java.math.*; import java.text.*; public class Main{ public static void main(String args[]) throws IOException { Read sc = new Read(); int t=sc.nextInt(); for(int i=0;i<t;i++){ int n=sc.nextInt(); int l=sc.nextInt(),r=sc.nextInt(); int arr[]=new int[n+1]; boolean ok=true; for(int j=1;j<=n;j++){ int k=r/j; k*=j; if(k>=l){ arr[j]=k; } else{ ok=false; sc.println("NO"); break; } } if(ok){ sc.println("YES"); for(int j=1;j<=n;j++){ sc.print(arr[j]+" "); } sc.println(""); } } sc.bw.flush(); } } class Read{ BufferedReader bf; StringTokenizer st; BufferedWriter bw; public Read(){ bf=new BufferedReader(new InputStreamReader(System.in)); st=new StringTokenizer(""); bw=new BufferedWriter(new OutputStreamWriter(System.out)); } public String nextLine() throws IOException{ return bf.readLine(); } public String next() throws IOException{ while(!st.hasMoreTokens()){ st=new StringTokenizer(bf.readLine()); } return st.nextToken(); } public char nextChar() throws IOException{ return next().charAt(0); } public int nextInt() throws IOException{ return Integer.parseInt(next()); } public long nextLong() throws IOException{ return Long.parseLong(next()); } public double nextDouble() throws IOException{ return Double.parseDouble(next()); } public float nextFloat() throws IOException{ return Float.parseFloat(next()); } public byte nextByte() throws IOException{ return Byte.parseByte(next()); } public short nextShort() throws IOException{ return Short.parseShort(next()); } public BigInteger nextBigInteger() throws IOException{ return new BigInteger(next()); } public void println(int a) throws IOException{ bw.write(String.valueOf(a)); bw.newLine(); return; } public void print(int a) throws IOException{ bw.write(String.valueOf(a)); return; } public void println(String a) throws IOException{ bw.write(a); bw.newLine(); return; } public void print(String a) throws IOException{ bw.write(a); return; } public void println(long a) throws IOException{ bw.write(String.valueOf(a)); bw.newLine(); return; } public void print(long a) throws IOException{ bw.write(String.valueOf(a)); return; } public void println(double a) throws IOException{ bw.write(String.valueOf(a)); bw.newLine(); return; } public void print(double a) throws IOException{ bw.write(String.valueOf(a)); return; } public void print(BigInteger a) throws IOException{ bw.write(a.toString()); return; } public void print(char a) throws IOException{ bw.write(String.valueOf(a)); return; } public void println(char a) throws IOException{ bw.write(String.valueOf(a)); bw.newLine(); return; } }
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
3c06c4bfc2b70aab7b8bd4fa6e83348f
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; /** * @author zengnianmei */ public class CodeForces { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); Solution solution = new Solution(); while(t-- > 0) { int n = scanner.nextInt(); int l = scanner.nextInt(); int r = scanner.nextInt(); solution.solve(n, l, r); } } } class Solution { public void solve(int n, int l , int r) { int[] ans = new int[n]; for (int i=1; i <= n; i++) { ans[i-1] = ((l-1) / i + 1) * i; if (ans[i-1] > r) { System.out.println("NO"); return ; } } System.out.println("YES"); for (int i=0; i < n; i++) { System.out.printf("%d ", ans[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
d979e0a4727612be0efb3dc2389d261c
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.min; import static java.lang.Math.max; import static java.lang.Math.abs; import java.util.*; import java.math.*; public class B_Difference_of_GCDs { public static void solve(Scanner in){ int n = in.nextInt(); int start = in.nextInt(); int end = in.nextInt(); int arr[] = new int[n+1]; boolean flag = false; for(int i = 1; i<=n; i++){ int num = (end/i)* i; if(num < start){ flag = true; break; } arr[i] = num; } if(flag == false){ System.out.println("YES"); for(int i = 1; i<=n; i++){ System.out.print(arr[i] + " "); } System.out.println(); } else{ System.out.println("NO"); } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int i = 0; i<t; i++){ solve(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 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
c07d6fdaa9327087201c5b80bddd3eb9
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 Test { static Scanner scan = new Scanner(System.in); public static void main(String[] args) { int t = Integer.parseInt(scan.nextLine()); for (int i = 0; i < t; i++) { boolean isPoss = true; ArrayList<Integer> ans = new ArrayList<>(); int n = scan.nextInt(), l = scan.nextInt(), r = scan.nextInt(); for (int j = 1; j <= n; j++) { if (findNum(l, j) > r) { isPoss = false; break; } ans.add(findNum(l, j)); } if (!isPoss) { System.out.println("NO"); continue; } System.out.println("YES"); for (int x: ans) { System.out.print(x + " "); } System.out.println(); } } static int findNum(int l, int k) { return ((l % k == 0)? l : l + k - (l % k)); } }
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
7a899a1e8698af7f92c954b153488352
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{ public static void main(String[] args) throws FileNotFoundException { InputStream inputStream = System.in; OutputStream outputStream = System.out; boolean oj = System.getProperty("ONLINE_JUDGE") != null; if (!oj) { inputStream = new FileInputStream(new File("input.txt")); //outputStream = new FileOutputStream(new File("output.txt")); } InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); solve(in, out); out.close(); } public static void solve(InputReader in, PrintWriter out) { int t = in.nextInt(); one: for (int i = 0; i < t; i++) { int n = in.nextInt(); int l = in.nextInt(), r = in.nextInt(); int[] a = new int[n]; for (int j = 1; j <= n; j++) { int num = ((l - 1) / j + 1) * j; if (num > r){ out.println("NO"); continue one; } a[j-1] = num; } out.println("YES"); for (int j = 0; j < n; j++) { out.print(a[j] + " "); } out.println(); } } 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(); } int nextInt() { return Integer.parseInt(next()); } 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 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
014370fbe0a3b2a1ba4e6417212426de
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.Arrays; import java.util.Scanner; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int tc = 0; tc < t; ++tc) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); System.out.println(solve(n, l, r)); } sc.close(); } static String solve(int n, int l, int r) { int[] result = new int[n]; for (int i = 0; i < result.length; ++i) { result[i] = r / (i + 1) * (i + 1); if (result[i] < l) { return "NO"; } } return String.format( "YES\n%s", Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining(" "))); } }
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
4b8496a507a99c44b2ee0e9f463c1314
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.Arrays; import java.util.StringTokenizer; import java.util.stream.IntStream; public class TaskB { public static void main(String[] args) { FastScanner in = new FastScanner(); PrintWriter out = new PrintWriter(System.out); TaskB s = new TaskB(); s.solve(in, out); out.flush(); } void solveOne(FastScanner in, PrintWriter out) { int n = in.nextInt(), l = in.nextInt(), r = in.nextInt(); int[] ans = IntStream.rangeClosed(1, n) .map(i -> r - r % i) .toArray(); boolean can = Arrays.stream(ans) .allMatch(x -> x >= l); if (can) { out.println("YES"); for (int i : ans) { out.printf("%d ", i); } out.println(""); } else { out.println("NO"); } } void solve(FastScanner in, PrintWriter out) { int t = 1; t = in.nextInt(); for (int tc = 1; tc <= t; tc++) { // out.printf("Case #%d: ", tc); solveOne(in, out); } } 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()); } long nextLong() { return Long.parseLong(next()); } float nextFloat() { return Float.parseFloat(next()); } double nextDouble() { 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 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
37540c2f4379f594dae1a7dbc4926260
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; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.StringTokenizer; public class Main { public static final boolean MULTIPLE_TESTCASES = true; static class Solution { public void solve() { var n = in.nextInt(); var l = in.nextInt(); var r = in.nextInt(); List<Integer> list = new ArrayList<>(); for (int i = 1; i <= n; ++i) { var value = (l % i == 0 ? l / i : l / i + 1) * i; if (value <= r) { list.add(value); } else { out.println("NO"); return; } } out.println("YES"); list.forEach(p -> out.print(p + " ")); out.println(); } private void swap(char[] arr, int i, int j) { var tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } private void shuffle(int[] a) { Random r = new Random(); for (var i = 0; i < a.length; i++) { var oi = r.nextInt(a.length); var temp = a[i]; a[i] = a[oi]; a[oi] = temp; } } // Initialise Solution class private final FastIOAdapter in; private final PrintWriter out; public Solution(FastIOAdapter in, PrintWriter out) { this.in = in; this.out = out; } } public static void main(String[] args) throws Exception { try (FastIOAdapter ioAdapter = new FastIOAdapter()) { int count = 1; if (MULTIPLE_TESTCASES) { count = ioAdapter.nextInt(); } Solution solution = new Solution(ioAdapter, ioAdapter.out); while (count-- > 0) { solution.solve(); } } } static class FastIOAdapter implements AutoCloseable { private final BufferedReader br; private final PrintWriter out; private StringTokenizer st = new StringTokenizer(""); public FastIOAdapter() { this.br = new BufferedReader(new InputStreamReader(System.in)); this.out = new PrintWriter(new BufferedWriter(new OutputStreamWriter((System.out)))); } String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } String nextLine() { try { return br.readLine(); } catch (IOException e) { e.printStackTrace(); return null; } } 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[] readArrayLong(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()); } @Override public void close() throws Exception { out.flush(); out.close(); br.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
44fb80105648eb89c088aa34f91d6315
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 { 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(); boolean lol = true; int[] arr = new int[n]; for(int i=0; i<n; i++){ if(l%(i+1)==0) arr[i] = l; else{ int q = i+1; int z = l+q-l%q; if(z<=r){ arr[i] = z; } else{ lol = false; break; } } } if(lol==true){ System.out.println("YES"); for(int i=0; i<n; i++){ System.out.print(arr[i] + " "); } System.out.print("\n"); } 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
4bf90154e40419cbde5ad957e1d22032
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 : Ryan Ranaut __Hope is a big word, never lose it__ ------------- --------------*/ import java.io.*; import java.util.*; public class Codeforces2 { static PrintWriter out = new PrintWriter(System.out); //static final int mod = 1_000_000_007; static final int mod = 998244353; static final int max = (int)(1e6); 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[] readIntArray(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()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } /*-------------------------------------------------------------------------*/ //Try seeing general case //Think edge cases public static void main(String[] args) { FastReader s = new FastReader(); int t = s.nextInt(); while(t-->0) { int n = s.nextInt(); long l = s.nextLong(); long r = s.nextLong(); find(n, l, r); } out.close(); } public static void find(int n, long l, long r) { List<Long> ls = new ArrayList<>(); ls.add(l);//For 1 for(int i=2;i<=n;i++) { long x = r%i; long val = r - x; if(val >= l) ls.add(val); else { out.println("NO"); return ; } } out.println("YES"); for(Long x: ls) out.print(x+" "); out.println(); } /*-----------------------------------End of the road--------------------------------------*/ static class DSU { int[] parent; int[] ranks; int[] groupSize; int size; public DSU(int n) { size = n; parent = new int[n];//0 based ranks = new int[n]; groupSize = new int[n];//Size of each component for (int i = 0; i < n; i++) { parent[i] = i; ranks[i] = 1; groupSize[i] = 1; } } public int find(int x)//Path Compression { if (parent[x] == x) return x; else return parent[x] = find(parent[x]); } public void union(int x, int y)//Union by rank { int x_rep = find(x); int y_rep = find(y); if (x_rep == y_rep) return; if (ranks[x_rep] < ranks[y_rep]) { parent[x_rep] = y_rep; groupSize[y_rep] += groupSize[x_rep]; } else if (ranks[x_rep] > ranks[y_rep]) { parent[y_rep] = x_rep; groupSize[x_rep] += groupSize[y_rep]; } else { parent[y_rep] = x_rep; ranks[x_rep]++; groupSize[x_rep] += groupSize[y_rep]; } size--;//Total connected components } } public static int gcd(int x,int y) { return y==0?x:gcd(y,x%y); } public static long gcd(long x,long y) { return y==0L?x:gcd(y,x%y); } public static int lcm(int a, int b) { return (a * b) / gcd(a, b); } public static long lcm(long a, long b) { return (a * b) / gcd(a, b); } public static long pow(long a,long b) { if(b==0L) return 1L; long tmp=1; while(b>1L) { if((b&1L)==1) tmp*=a; a*=a; b>>=1; } return (tmp*a); } public static long modPow(long a,long b,long mod) { if(b==0L) return 1L; long tmp=1; while(b>1L) { if((b&1L)==1L) tmp*=a; a*=a; a%=mod; tmp%=mod; b>>=1; } return (tmp*a)%mod; } static long mul(long a, long b) { return a*b%mod; } static long fact(int n) { long ans=1; for (int i=2; i<=n; i++) ans=mul(ans, i); return ans; } 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 void debug(int ...a) { for(int x: a) out.print(x+" "); out.println(); } static void debug(long ...a) { for(long x: a) out.print(x+" "); out.println(); } static void debugMatrix(int[][] a) { for(int[] x:a) out.println(Arrays.toString(x)); } static void debugMatrix(long[][] a) { for(long[] x:a) out.println(Arrays.toString(x)); } static void reverseArray(int[] a) { int n = a.length; int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = a[n - i - 1]; for (int i = 0; i < n; i++) a[i] = arr[i]; } static void reverseArray(long[] a) { int n = a.length; long[] arr = new long[n]; for (int i = 0; i < n; i++) arr[i] = a[n - i - 1]; for (int i = 0; i < n; i++) a[i] = arr[i]; } static void sort(int[] a) { ArrayList<Integer> ls = new ArrayList<>(); for(int x: a) ls.add(x); Collections.sort(ls); for(int i=0;i<a.length;i++) a[i] = ls.get(i); } static void sort(long[] a) { ArrayList<Long> ls = new ArrayList<>(); for(long x: a) ls.add(x); Collections.sort(ls); for(int i=0;i<a.length;i++) a[i] = ls.get(i); } static class Pair{ int x, y; Pair(int x, int y) { this.x = x; this.y = y; } } }
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
03f6d03668ee39bc7b9b843030f46e51
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 { public static void main(String[] args) throws IOException { Soumit sc = new Soumit(); int tc = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (tc-->0){ int n = sc.nextInt(); long l = sc.nextInt(); long r = sc.nextInt(); long[] a = new long[n]; boolean flag = true; for(int i=0;i<n;i++){ long v = (l + i) / (i + 1); a[i] = v * (i + 1); if(a[i] > r){ flag = false; break; } } if(flag){ sb.append("YES\n"); for(long i: a){ sb.append(i).append(" "); } sb.append("\n"); } else{ sb.append("NO\n"); } } System.out.println(sb); sc.close(); } static class Soumit { final private int BUFFER_SIZE = 1 << 18; final private DataInputStream din; final private byte[] buffer; private PrintWriter pw; private int bufferPointer, bytesRead; StringTokenizer st; public Soumit() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Soumit(String file_name) throws IOException { din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public void streamOutput(String file) throws IOException { FileWriter fw = new FileWriter(file); BufferedWriter bw = new BufferedWriter(fw); pw = new PrintWriter(bw); } public void println(String a) { pw.println(a); } public void print(String a) { pw.print(a); } public String readLine() throws IOException { byte[] buf = new byte[3000064]; // line length int cnt = 0, c; while ((c = read()) != -1) { if (c == '\n') break; buf[cnt++] = (byte) c; } return new String(buf, 0, cnt); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } public void sort(int[] arr) { ArrayList<Integer> arlist = new ArrayList<>(); for (int i : arr) arlist.add(i); Collections.sort(arlist); for (int i = 0; i < arr.length; i++) arr[i] = arlist.get(i); } public void sort(long[] arr) { ArrayList<Long> arlist = new ArrayList<>(); for (long i : arr) arlist.add(i); Collections.sort(arlist); for (int i = 0; i < arr.length; i++) arr[i] = arlist.get(i); } public int[] nextIntArray(int n) throws IOException { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = nextInt(); } return arr; } public long[] nextLongArray(int n) throws IOException { long[] arr = new long[n]; for (int i = 0; i < n; i++) { arr[i] = nextLong(); } return arr; } public double[] nextDoubleArray(int n) throws IOException { double[] arr = new double[n]; for (int i = 0; i < n; i++) { arr[i] = nextDouble(); } return arr; } 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;*/ if (din != null) din.close(); if (pw != null) 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 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
e55f7582966f705f4e796c33dbbe5cc9
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.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class Round808B { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String IMPOSSIBLE = "IMPOSSIBLE"; final static String POSSIBLE = "POSSIBLE"; final static String YES = "YES"; final static String NO = "NO"; private void initIO(boolean isFileIO) { if (System.getProperty("ONLINE_JUDGE") == null && isFileIO) { try{ in = new MyScanner(new FileInputStream("input.txt")); out = new MyPrintWriter(new FileOutputStream("output.txt")); } catch(FileNotFoundException e){ e.printStackTrace(); } } else{ in = new MyScanner(System.in); out = new MyPrintWriter(new BufferedOutputStream(System.out)); } } public static void main(String[] args){ // Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); Round808B sol = new Round808B(); sol.run(); } private void run() { boolean isDebug = false; boolean isFileIO = true; boolean hasMultipleTests = true; initIO(isFileIO); int t = hasMultipleTests? in.nextInt() : 1; for (int i = 1; i <= t; ++i) { int n = in.nextInt(); int l = in.nextInt(); int r = in.nextInt(); int[] ans = solve(n, l, r); if(ans == null) out.println(NO); else { out.println(YES); out.printlnAns(ans); } if(isDebug) out.flush(); } in.close(); out.close(); } private int[] solve(int n, int l, int r) { // l <= ai <= r // gcd(i, ai) all distinct // gcd(1, a1) = 1 // gcd(2, a2) = 2 (can't be 1) -> a2 = 2k // gcd(3, a3) = 3 -> a3 = 3k // gcd(n, an) = n -> an = nk int[] ans = new int[n]; for(int i=1; i<=n; i++) { int remainder = l % i; if(remainder == 0) ans[i-1] = l; else ans[i-1] = l + (i-remainder); if(ans[i-1] > r) return null; } return ans; } public static class MyScanner { BufferedReader br; StringTokenizer st; // 32768? public MyScanner(InputStream is, int bufferSize) { br = new BufferedReader(new InputStreamReader(is), bufferSize); } public MyScanner(InputStream is) { br = new BufferedReader(new InputStreamReader(is)); // br = new BufferedReader(new InputStreamReader(System.in)); // br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"))); } public void close() { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } 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[][] nextTreeEdges(int n, int offset){ int[][] e = new int[n-1][2]; for(int i=0; i<n-1; i++){ e[i][0] = nextInt()+offset; e[i][1] = nextInt()+offset; } return e; } int[][] nextMatrix(int n, int m) { return nextMatrix(n, m, 0); } int[][] nextMatrix(int n, int m, int offset) { int[][] mat = new int[n][m]; for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { mat[i][j] = nextInt()+offset; } } return mat; } int[][] nextPairs(int n){ return nextPairs(n, 0); } int[][] nextPairs(int n, int offset) { int[][] xy = new int[2][n]; for(int i=0; i<n; i++) { xy[0][i] = nextInt() + offset; xy[1][i] = nextInt() + offset; } return xy; } int[][] nextGraphEdges(){ return nextGraphEdges(0); } int[][] nextGraphEdges(int offset) { int m = nextInt(); int[][] e = new int[m][2]; for(int i=0; i<m; i++){ e[i][0] = nextInt()+offset; e[i][1] = nextInt()+offset; } return e; } int[] nextIntArray(int len) { return nextIntArray(len, 0); } int[] nextIntArray(int len, int offset){ int[] a = new int[len]; for(int j=0; j<len; j++) a[j] = nextInt()+offset; return a; } long[] nextLongArray(int len) { return nextLongArray(len, 0); } long[] nextLongArray(int len, int offset){ long[] a = new long[len]; for(int j=0; j<len; j++) a[j] = nextLong()+offset; return a; } } public static class MyPrintWriter extends PrintWriter{ public MyPrintWriter(OutputStream os) { super(os); } public void printlnAns(long ans) { println(ans); } public void printlnAns(int ans) { println(ans); } public void printlnAns(boolean ans) { if(ans) println(YES); else println(NO); } public void printAns(long[] arr){ if(arr != null && arr.length > 0){ print(arr[0]); for(int i=1; i<arr.length; i++){ print(" "); print(arr[i]); } } } public void printlnAns(long[] arr){ printAns(arr); println(); } public void printAns(int[] arr){ if(arr != null && arr.length > 0){ print(arr[0]); for(int i=1; i<arr.length; i++){ print(" "); print(arr[i]); } } } public void printlnAns(int[] arr){ printAns(arr); println(); } public <T> void printAns(ArrayList<T> arr){ if(arr != null && arr.size() > 0){ print(arr.get(0)); for(int i=1; i<arr.size(); i++){ print(" "); print(arr.get(i)); } } } public <T> void printlnAns(ArrayList<T> arr){ printAns(arr); println(); } public void printAns(int[] arr, int add){ if(arr != null && arr.length > 0){ print(arr[0]+add); for(int i=1; i<arr.length; i++){ print(" "); print(arr[i]+add); } } } public void printlnAns(int[] arr, int add){ printAns(arr, add); println(); } public void printAns(ArrayList<Integer> arr, int add) { if(arr != null && arr.size() > 0){ print(arr.get(0)+add); for(int i=1; i<arr.size(); i++){ print(" "); print(arr.get(i)+add); } } } public void printlnAns(ArrayList<Integer> arr, int add){ printAns(arr, add); println(); } public void printlnAnsSplit(long[] arr, int split){ if(arr != null){ for(int i=0; i<arr.length; i+=split){ print(arr[i]); for(int j=i+1; j<i+split; j++){ print(" "); print(arr[j]); } println(); } } } public void printlnAnsSplit(int[] arr, int split){ if(arr != null){ for(int i=0; i<arr.length; i+=split){ print(arr[i]); for(int j=i+1; j<i+split; j++){ print(" "); print(arr[j]); } println(); } } } public <T> void printlnAnsSplit(ArrayList<T> arr, int split){ if(arr != null && !arr.isEmpty()){ for(int i=0; i<arr.size(); i+=split){ print(arr.get(i)); for(int j=i+1; j<i+split; j++){ print(" "); print(arr.get(j)); } println(); } } } } static private void permutateAndSort(long[] a) { int n = a.length; Random R = new Random(System.currentTimeMillis()); for(int i=0; i<n; i++) { int t = R.nextInt(n-i); long temp = a[n-1-i]; a[n-1-i] = a[t]; a[t] = temp; } Arrays.sort(a); } static private void permutateAndSort(int[] a) { int n = a.length; Random R = new Random(System.currentTimeMillis()); for(int i=0; i<n; i++) { int t = R.nextInt(n-i); int temp = a[n-1-i]; a[n-1-i] = a[t]; a[t] = temp; } Arrays.sort(a); } static private int[][] constructChildren(int n, int[] parent, int parentRoot){ int[][] childrens = new int[n][]; int[] numChildren = new int[n]; for(int i=0; i<parent.length; i++) { if(parent[i] != parentRoot) numChildren[parent[i]]++; } for(int i=0; i<n; i++) { childrens[i] = new int[numChildren[i]]; } int[] idx = new int[n]; for(int i=0; i<parent.length; i++) { if(parent[i] != parentRoot) childrens[parent[i]][idx[parent[i]]++] = i; } return childrens; } static private int[][][] constructDirectedNeighborhood(int n, int[][] e){ int[] inDegree = new int[n]; int[] outDegree = new int[n]; for(int i=0; i<e.length; i++) { int u = e[i][0]; int v = e[i][1]; outDegree[u]++; inDegree[v]++; } int[][] inNeighbors = new int[n][]; int[][] outNeighbors = new int[n][]; for(int i=0; i<n; i++) { inNeighbors[i] = new int[inDegree[i]]; outNeighbors[i] = new int[outDegree[i]]; } int[] inIdx = new int[n]; int[] outIdx = new int[n]; for(int i=0; i<e.length; i++) { int u = e[i][0]; int v = e[i][1]; outNeighbors[u][outIdx[u]++] = v; inNeighbors[v][inIdx[v]++] = u; } return new int[][][] {inNeighbors, outNeighbors}; } static private int[][] constructNeighborhood(int n, int[][] e) { int[] degree = new int[n]; for(int i=0; i<e.length; i++) { int u = e[i][0]; int v = e[i][1]; degree[u]++; degree[v]++; } int[][] neighbors = new int[n][]; for(int i=0; i<n; i++) neighbors[i] = new int[degree[i]]; int[] idx = new int[n]; for(int i=0; i<e.length; i++) { int u = e[i][0]; int v = e[i][1]; neighbors[u][idx[u]++] = v; neighbors[v][idx[v]++] = u; } return neighbors; } static private void drawGraph(int[][] e) { makeDotUndirected(e); try { final Process process = new ProcessBuilder("dot", "-Tpng", "graph.dot") .redirectOutput(new File("graph.png")) .start(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } static private void makeDotUndirected(int[][] e) { MyPrintWriter out2 = null; try { out2 = new MyPrintWriter(new FileOutputStream("graph.dot")); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } out2.println("strict graph {"); for(int i=0; i<e.length; i++){ out2.println(e[i][0] + "--" + e[i][1] + ";"); } out2.println("}"); out2.close(); } static private void makeDotDirected(int[][] e) { MyPrintWriter out2 = null; try { out2 = new MyPrintWriter(new FileOutputStream("graph.dot")); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } out2.println("strict digraph {"); for(int i=0; i<e.length; i++){ out2.println(e[i][0] + "->" + e[i][1] + ";"); } out2.println("}"); out2.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
cd281e397581fffcba20abb9ca934c96
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[] arguments) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); a:for(int in=0;in<t;in++) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int arr[] = new int[n]; for(int i=1;i<=n;i++){ int k=(l/i)*i; while(k<l)k+=i; if(k>r || k== 0 ) { System.out.println("NO"); continue a; } arr[i-1]=k; } { 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 8
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
20842af588f3fff6fd9047745316be89
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
/****************************************************************************** Practice,Practice and Practice....!! *******************************************************************************/ 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.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 FastWriter { private final BufferedWriter bw; public FastWriter() { this.bw = new BufferedWriter(new OutputStreamWriter(System.out)); } public void print(Object object) throws IOException { bw.append("" + object); } public void println(Object object) throws IOException { print(object); bw.append("\n"); } public void close() throws IOException { bw.close(); } } public static void main(String[] args) { try { FastReader in=new FastReader(); FastWriter out = new FastWriter(); int testCases=in.nextInt(); while(testCases-- > 0){ int n=in.nextInt(); int l=in.nextInt(); int r=in.nextInt(); boolean b=true; for(int i=1;i<=n;i++){ if(l%i==0 || r%i==0 || (i>l && i<r)) continue; if((l>i && ((l/i)*i)+i>r) ||(i>l && ((r/i)*i)-i<l )) { b=false; break; } } if(b==false) out.print("NO"); else{ out.println("YES"); for(int i=1;i<=n;i++){ if(i<=l){ if(l%i==0) out.print(l+" "); else{ int t=l/i; out.print((t*i)+i+" "); } } else{ if(r%i==0) out.print(r+" "); else{ int t=r/i; if((t*i)-i==0) out.print(i+" "); else out.print((t*i)-i+" "); } } } } out.println(""); } out.close(); } catch (Exception e) { return; } } }
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 8
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
5b4c8094ba02c64948f9c37780f8c5e8
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.*; import static java.lang.Math.*; public class Main { static class Reader { public BufferedReader br; StringTokenizer st = new StringTokenizer(""); public Reader() { this(System.in); } public Reader(InputStream input) { br = new BufferedReader(new InputStreamReader(input)); } String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int ni() { return Integer.parseInt(next()); } long nl() { return Long.parseLong(next()); } double nd() { return Double.parseDouble(next()); } String nextl() { String str = ""; try { str = br.readLine().trim(); } catch (Exception e) { e.printStackTrace(); } return str; } int[] arrin(long num) { int n = (int) num; int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = ni(); return a; } long[] arrnl(long num) { int n = (int) num; long[] l = new long[n]; for (int i = 0; i < n; i++) l[i] = nl(); return l; } } //<------------------------------------------------WRITER----------------------------> static class Writer { static PrintWriter out; public Writer() { this(System.out); } public Writer(OutputStream outs) { out = new PrintWriter(outs); } public void pl(int i) { out.println(i); } public void pl(long l) { out.println(l); } public void pl(double d) { out.println(d); } public void pl(String s) { out.println(s); } public void p(int i) { out.print(i); } public void p(long l) { out.print(l); } public void p(double d) { out.print(d); } public void p(String s) { out.print(s); } public void p() { out.println(); } public void close() { out.close(); } } //-----------------------------------------------------------------------------------> //--------------------------VARIABLES------------------------------------// static Reader in = new Reader(); static OutputStream outputStream = System.out; static Writer out = new Writer(outputStream); static long lmax = Long.MAX_VALUE, lmin = Long.MIN_VALUE; static int imax = Integer.MAX_VALUE, imin = Integer.MIN_VALUE; static long mod = 1000000007; //-----------------------------------------------------------------------// //--------------------------Red_Hair-----------------------------------// private static void Red_Hair() throws IOException { String FILE = "RED"; try {FILE = System.getProperty("user.dir");} catch (Exception e) { } if(new File(FILE).getName().equals("CP")){ out = new Writer(new FileOutputStream("output.txt")); in = new Reader(new FileInputStream("input.txt")); } } //-----------------------------------------------------------------------// public static void main(String[] args) throws IOException { Red_Hair(); int t = in.ni(); while (t-- > 0) solve(); out.close(); } static void solve() throws IOException { int n = in.ni(); int l = in.ni(); int r = in.ni(); ArrayList<Integer> list = new ArrayList<>(); int cnt =1; list.add(l); for (int i = 2; i <=n; i++) { if(l%i==0){ list.add(l); cnt++; }else{ int j = ((l-1)/i+1)*i; if(j<=r){ list.add(j); cnt++; }else{ break; } } } if(cnt!=n){ out.pl("NO"); }else { out.pl("YES"); for (int a : list) { out.p(a + " "); } out.pl(""); } } 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 * b / gcd(a, b); } static class pr <T extends Comparable<T>, V extends Comparable<V>> implements Comparable<pr<T, V>> { T a; V b; public pr(T a, V b) { this.a = a; this.b = b; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof pr)) return false; pr<?, ?> pr = (pr<?, ?>) o; return a.equals(pr.a) && b.equals(pr.b); } @Override public int hashCode() { return Objects.hash(a, b); } @Override public int compareTo(pr o) { return this.a.compareTo(((T) o.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 8
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
5ef28c14538d590c136a895bbecb3abd
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.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { new Thread(null, () -> new Main().run(), "1", 1 << 23).start(); } private void run() { FastReader scan = new FastReader(); PrintWriter out = new PrintWriter(System.out); Solution solve = new Solution(); int t = scan.nextInt(); //int t = 1; for (int qq = 0; qq < t; qq++) { solve.solve(scan, out); out.println(); } out.close(); } static class Solution { /* * think and coding */ public void solve(FastReader scan, PrintWriter out) { int n = scan.nextInt(), l = scan.nextInt(), r = scan.nextInt(); ArrayList<Integer> a = new ArrayList<>(); int index = 1; while (a.size() < n) { int x = l; if (x % index != 0) { x += index - (x % index); } if (x > r) { out.print("NO"); return; } a.add(x); index++; } out.println("YES"); for (int i : a) { out.print(i + " "); } } } static class FastReader { private final BufferedReader br; private StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(String s) throws FileNotFoundException { br = new BufferedReader(new FileReader(new File(s))); } 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; } } static class MathForces { static int modI = (int) 1e9; static long modL = (long) 1e9; static BigInteger gcd(BigInteger a, BigInteger b) { if (a.compareTo(BigInteger.valueOf(0)) == 0) return b; return gcd(b.mod(a), a); } static BigInteger lcm(BigInteger a, BigInteger b) { return a.multiply(b).abs().divide(gcd(a, b)); } 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 Math.abs(a * b) / gcd(a, b); } static int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } static int lcm(int a, int b) { return Math.abs(a * b) / gcd(a, b); } static long sumNum(String s) { char[] arr = s.toCharArray(); long sum = 0; for (char c : arr) { sum += c - '0'; } return sum; } static long fPow(long a, long n) { if (n == 0) return 1; if (n % 2 == 1) return fPow(a, n - 1) * a; else { long b = fPow(a, n / 2); return b * b; } } static long fPowMod(long a, long n, long MOD) { if (n == 0L) return 1L; if (n % 2 == 1) { return (a * fPowMod(a, n - 1, MOD)) % MOD; } long temp = fPowMod(a, n / 2, MOD); return (temp * temp) % MOD; } static void swap(int[] arr, int a, int b) { int temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } } static class Point { public int a, b, c; public Point(int a, int b) { this.a = a; this.b = b; } public Point(int a, int b, int c) { this.a = a; this.b = b; this.c = c; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Point point = (Point) o; return a == point.a && b == point.b && c == point.c; } @Override public int hashCode() { return Objects.hash(a, b, c); } } static class Comp implements Comparator<String> { public int compare(String o1, String o2) { return Integer.compare(o1.length(), o2.length()); } } }
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 8
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
75f7e8bb090972747ad721b181316c92
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 jdk.internal.org.jline.utils.InputStreamReader; import java.io.*; public final class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Map<Integer, Integer> megamap = new HashMap<>(); int t = Integer.parseInt(br.readLine()); while (t-- > 0) { String arri[] = br.readLine().split(" "); int arr[] = new int[arri.length]; for (int i = 0; i < 3; i++) arr[i] = Integer.parseInt(arri[i]); int n = arr[0]; int l = arr[1]; int r = arr[2]; Map<Integer, Integer> map = new HashMap<>(); for (int i = 1; i <= n; i++) { if(l%i==0)map.put(i,l); else{ int temp=l/i; temp=(temp+1)*i; if(temp<=r)map.put(i,temp); } } if (map.size() != n) System.out.println("NO"); else { System.out.println("YES"); for (int i = 1; i <= n; i++) System.out.print(map.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 8
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
83abb05a02a52fe10006782854bef2f6
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{ public static void main(String[] args) throws FileNotFoundException { InputStream inputStream = System.in; OutputStream outputStream = System.out; boolean oj = System.getProperty("ONLINE_JUDGE") != null; if (!oj) { inputStream = new FileInputStream(new File("input.txt")); //outputStream = new FileOutputStream(new File("output.txt")); } InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); solve(in, out); out.close(); } public static void solve(InputReader in, PrintWriter out) { int t = in.nextInt(); one: for (int i = 0; i < t; i++) { int n = in.nextInt(); int l = in.nextInt(), r = in.nextInt(); int[] a = new int[n]; for (int j = 1; j <= n; j++) { int num = ((l - 1) / j + 1) * j; if (num > r){ out.println("NO"); continue one; } a[j-1] = num; } out.println("YES"); for (int j = 0; j < n; j++) { out.print(a[j] + " "); } out.println(); } } 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(); } int nextInt() { return Integer.parseInt(next()); } 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 8
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
21327a812fdccf8139bb37cf86d8e218
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 static java.lang.Math.*; public class MainB { 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(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public boolean hasNext() { try { String string = reader.readLine(); if (string == null) { return false; } tokenizer = new StringTokenizer(string); return tokenizer.hasMoreTokens(); } catch (IOException e) { return false; } } } static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); static void ini() { } static String yes = "YES"; static String no = "NO"; static int ipInf = Integer.MAX_VALUE-5; static int inInf = Integer.MIN_VALUE+5; static long lpInf = Long.MAX_VALUE - 5; static long lnInf = Long.MIN_VALUE + 5; public static void main(String[] args) { int t = in.nextInt(); ini(); while (t -- > 0) { solve(); } out.close(); } static void solve() { int n = in.nextInt(); int l = in.nextInt(); int r = in.nextInt(); boolean flag = true; int[] res = new int[n+1]; for (int i = 1; i <= n; i++) { res[i] = ((l-1)/i + 1) * i; flag &= res[i] <= r; } out.println(flag ? yes : no); if (flag) { printArr(res); } } static void printArr (int[] arr) { int n = arr.length; if (n == 1) return; for (int i = 1; i < n-1; i++) { out.print(arr[i] + " "); } out.println(arr[n-1]); } static void printArr (long[] arr) { int n = arr.length; if (n == 0) return; for (int i = 0; i < n-1; i++) { out.print(arr[i] + " "); } out.println(arr[n-1]); } static long _gcd (long a, long b) { long temp; while (true) { temp = a % b; if (temp == 0) return b; a = b; b = temp; } } }
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 8
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
a3a33815df0449ebe8ed5b09715a10da
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 kriti; import java.math.*; import java.io.*; import java.util.*; public class A { static PrintWriter out = new PrintWriter(System.out); static StringBuilder res=new StringBuilder(); static FastReader in=new FastReader(); static PriorityQueue<Integer> pq,pq2; static HashSet<Long> h; static HashMap<Long, Integer> mp,mp2 ; public static void main(String args[])throws IOException { int k =i(); outer:while(k-->0) { long n=l(); long j=l(); long r=l(); long[] A=new long[(int)n]; HashSet<Long> h=new HashSet<>(); long l=j;int f=0; for(int i=1;i<=n;i++) { if((j-1)/i < r/i) { A[i-1]=r-(r%i); } else { f=1; System.out.println("NO"); break; } } if(f==0) { System.out.println("YES"); print(A); } } out.close(); } static int funct(char[] X, char x) { int c =0; for(int i=0;i<X.length;i++) { if(X[i]==x) { c++; while(i<X.length && X[i]==x)i++; } } return c; } static int[] Swap(int[] A, int i, int j) { int temp = A[i]; A[i]=A[j]; A[j]=temp; return A; } static String ChartoString(char[] x) { String ans=""; for(char i:x) { ans+=i; } return ans; } static int HCF(int num1, int num2) { int temp1 = num1; int temp2 = num2; while(temp2 != 0){ int temp = temp2; temp2 = temp1%temp2; temp1 = temp; } int hcf = temp1; return hcf; } static boolean palindrome(String s) { char[] x = s.toCharArray(); int i=0; int r= x.length-1; while(i<r) { if(x[i]!=x[r]) { return false; } i++; r--; } return true; } static void sorting(long[] a) //check for long { 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 boolean equal(int[] A) { int cnt=1;int prev=A[0]; for(int i=1;i<A.length;i++) { if(A[i]==prev)cnt++; } if(cnt==A.length)return true; return false; } static int findGcd(int x, int y) { if (x == 0) return y; return findGcd(y % x, x); } static int findLcm(int x, int y) { return (x / findGcd(x, y)) * y; } public static int checkTriangle(long a, long b, long c) { if (a + b <= c || a + c <= b || b + c <= a) return 0; else return 1; } static boolean isSorted(long A[]) { for(int i=1; i<A.length; i++)if(A[i]<=A[i-1])return false; return true; } static void print(char A[]) { for(char c:A)System.out.print(c); System.out.println(); } static void print(boolean A[]) { for(boolean c:A)System.out.print(c+" "); System.out.println(); } static void print(int A[]) { for(int a:A)System.out.print(a); System.out.println(); } static void print(long A[]) { for(long i:A)System.out.print(i+ " "); System.out.println(); } static void print(ArrayList<Integer> A) { for(long a:A)System.out.print(a); System.out.println(); } static void sort(long[] a) //check for long { 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 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 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 i() { return in.nextInt(); } static long l() { return in.nextLong(); } static String S() { return in.next(); } static int[] input(int N){ int A[]=new int[N]; for(int i=0; i<N; i++) { A[i]=in.nextInt(); } return A; } static long[] inputLong(int N) { long A[]=new long[N]; for(int i=0; i<A.length; i++)A[i]=in.nextLong(); return A; } } 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 8
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
635821eb9685d2342fe98a61121c5bd9
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 Solution { 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 main(String[] args) throws IOException{ // try { // System.setIn(new FileInputStream("input.txt")); // System.setOut(new PrintStream(new FileOutputStream("output.txt"))); // } catch (Exception e) { // System.err.println("Error"); // } FastReader in = new FastReader(); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out, "UTF-8"))); int t = in.nextInt(); while(t-- > 0) { int n = in.nextInt(); int l = in.nextInt(); int r = in.nextInt(); // int[] arr = new int[n]; // for(int i = 0; i < n; i++) { // arr[i] = in.nextInt(); // } solve(n, l, r); System.out.println(); } } static void solve(long n, long l, long r) { List<Long> list = new ArrayList<>(); for(long i = 1; i <= n; i++) { long mul = (int)Math.ceil(l / (1.0 * i)); long s = i*mul; boolean flag = false; if(s >= l && s <= r) { list.add(s); flag = true; } if(!flag) { System.out.print("NO"); return; } } System.out.println("YES"); for(int i = 0; i < list.size(); i++) { System.out.print(list.get(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 8
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
f4d578dae36f1fea82dc1abae84df433
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.Arrays; import java.util.StringTokenizer; import java.util.*; import static java.lang.System.out; import static java.lang.Math.*; public class pre174 { 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; } } static int gcd(int a,int b){ if(a==0) return b; return gcd(b%a,a); } public static void main(String args[]) { FastReader obj = new FastReader(); int tc = obj.nextInt(); while(tc--!=0){ int n = obj.nextInt(),l = obj.nextInt(),r = obj.nextInt(); int arr[] = new int[n+1]; /* Set<Integer> set = new HashSet<>(); arr[1] = l; set.add(1); for(int i=2;i<=n;i++){ int k = l/i; while(set.contains(gcd((k+1)*i,i))) k++; arr[i] = (k+1)*i; set.add(gcd((k+1)*i,i)); } //out.println(Arrays.toString(arr)); set.clear(); boolean ans = true; for(int i=1;i<=n;i++){ ans = !set.contains(gcd(arr[i],i)) && arr[i]<=r ; set.add(gcd(arr[i],i)); } if(!ans) out.println("NO"); else{ out.println("YES"); for(int i=1;i<=n;i++) out.print(arr[i]+" "); out.println(); } */ arr[1] = l; Set<Integer> set = new HashSet<>(); for(int i=2;i<=n;i++){ int k = (l%i==0)?l/i:l/i+1; while(set.contains(gcd((k)*i,i))) k++; arr[i] = (k)*i; set.add(gcd((k)*i,i)); } boolean ans = true; for(int i=1;i<=n;i++){ ans &= arr[i]<=r; } // out.println(set); if(!ans) out.println("NO"); else{ out.println("YES"); for(int i=1;i<=n;i++) out.print(arr[i]+" "); 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 8
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
b5992794a9bbabe5ddc85576f70c9135
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.util.Arrays; /* 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 scan = new Scanner(System.in); int T = scan.nextInt(); for(int i = 0; i < T; i++) { int N = scan.nextInt(); int L= scan.nextInt(); int R = scan.nextInt(); int[] ans = new int[N]; boolean a = true; for(int j = 0; j < N; j++) { int idx = j+1; if(L%idx == 0) { ans[j] = L; }else{ int L1 = L + idx - L%idx; if(L1<=R) { ans[j] = L1; }else{ a = false; break; } } } if(a == true) { System.out.println("YES"); for(int j = 0; j < N; j++) { System.out.print(ans[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 8
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
06f2dd3b9298606eebf1bd3a2cd11f71
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
// Piyush Nagpal import java.util.*; import java.io.*; import java.util.regex.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.ParseException; public class Main{ static int MOD=1000000007; static PrintWriter pw; static FastReader sc; 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());} public char nextChar() throws IOException {return next().charAt(0);} String nextLine(){ String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } public int[] intArr(int a,int b,int n) throws IOException {int[]in=new int[n];for(int i=a;i<b;i++)in[i]=nextInt();return in;} public long[] longArr(int a,int b,int n) throws IOException {long[]in=new long[n];for(int i=a;i<b;i++)in[i]=nextLong();return in;} public ArrayList<Integer> intlist(int n)throws IOException {ArrayList<Integer> list= new ArrayList<>();for(int i=0;i<n;i++)list.add(nextInt());return list;} public ArrayList<Long> longlist(int n)throws IOException {ArrayList<Long> list= new ArrayList<>();for(int i=0;i<n;i++)list.add(nextLong());return list;} } public static long gcd(long a,long b){if( b>a ){return gcd(b,a);}if( b==0 ){return a;} return gcd(b,a%b);} public static long expo( long a,long b,long M ){long result=1;while(b>0){if( b%2==1 ){result=(result*a)%M;}a=(a*a)%M;b=b/2;}return result%M;} public static ArrayList<Long> Sieve(int n){boolean [] arr= new boolean[n+1];Arrays.fill(arr, true);ArrayList<Long> list= new ArrayList<>();for(int i=2;i<=n;i++){if( arr[i]==true ){list.add((long)i);}for(int j=2*i;j<=n;j+=i){arr[j]=false;}}return list;} public static int lower_bound(int [] arr,int n,int x){ //first ele>=x ka idx int low=0,high=n-1;int ans=n; while(low<=high){int mid= low+(high-low)/2;if( arr[mid]>=x ){ans=mid;high=mid-1;}else{low=mid+1;}} return ans; } public static int lower_boundlist(ArrayList<Integer> list,int n,int x){ //first ele>=x ka idx int low=0,high=n-1;int ans=n; while(low<=high){int mid= low+(high-low)/2;if( list.get(mid)>=x ){ans=mid;high=mid-1;}else{low=mid+1;}} return ans; } public static int upper_bound(int [] arr,int n,int x){ //first ele>x ka idx int low=0,high=n-1;int ans=n; while(low<=high){int mid= low+(high-low)/2;if( arr[mid]<=x ){low=mid+1;}else{ans=mid;high=mid-1;}} return ans; } public static void parr(int [] arr){for(int i=0;i<arr.length;i++){pw.print(arr[i]+" ");}} public static void parr(long [] arr){for(int i=0;i<arr.length;i++){pw.print(arr[i]+" ");}} public static void plist(ArrayList<Integer> list){for(int i=0;i<list.size();i++){pw.print(list.get(i)+" ");}} public static void pllist(ArrayList<Long> list){for(int i=0;i<list.size();i++){pw.print(list.get(i)+" ");}} // int [] arr=sc.intArr(a,b,n); <b static void solve() throws Exception{ int n = sc.nextInt(),l=sc.nextInt(),r=sc.nextInt(); // if( r-l+1 < n ){ // pw.println("NO"); // return; // } int [] arr= new int [n]; for(int i=1;i<=n;i++){ if(l%i==0){ arr[i-1]=l; }else{ if( (l + (i-(l%i))) <=r ){ arr[i-1]=l+(i-(l%i)); }else{ pw.println("NO"); return; } } } pw.println("YES"); parr(arr); pw.println(); } public static void main(String[] args) throws Exception{ try { System.setIn(new FileInputStream("input.txt")); System.setOut(new PrintStream(new FileOutputStream("output.txt"))); } catch (Exception e) { System.err.println("Error"); } sc= new FastReader(); pw = new PrintWriter(System.out); int tc=1; tc=sc.nextInt(); for(int i=1;i<=tc;i++) { // pw.printf("Case #%d: ", i); solve(); } pw.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 8
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
1a6820d1ddfb9d69429bd0241acb1834
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
// Piyush Nagpal import java.util.*; import java.io.*; import java.util.regex.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.ParseException; public class Main{ static int MOD=1000000007; static PrintWriter pw; static FastReader sc; 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());} public char nextChar() throws IOException {return next().charAt(0);} String nextLine(){ String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } public int[] intArr(int a,int b,int n) throws IOException {int[]in=new int[n];for(int i=a;i<b;i++)in[i]=nextInt();return in;} public long[] longArr(int a,int b,int n) throws IOException {long[]in=new long[n];for(int i=a;i<b;i++)in[i]=nextLong();return in;} public ArrayList<Integer> intlist(int n)throws IOException {ArrayList<Integer> list= new ArrayList<>();for(int i=0;i<n;i++)list.add(nextInt());return list;} public ArrayList<Long> longlist(int n)throws IOException {ArrayList<Long> list= new ArrayList<>();for(int i=0;i<n;i++)list.add(nextLong());return list;} } public static long gcd(long a,long b){if( b>a ){return gcd(b,a);}if( b==0 ){return a;} return gcd(b,a%b);} public static long expo( long a,long b,long M ){long result=1;while(b>0){if( b%2==1 ){result=(result*a)%M;}a=(a*a)%M;b=b/2;}return result%M;} public static ArrayList<Long> Sieve(int n){boolean [] arr= new boolean[n+1];Arrays.fill(arr, true);ArrayList<Long> list= new ArrayList<>();for(int i=2;i<=n;i++){if( arr[i]==true ){list.add((long)i);}for(int j=2*i;j<=n;j+=i){arr[j]=false;}}return list;} public static int lower_bound(int [] arr,int n,int x){ //first ele>=x ka idx int low=0,high=n-1;int ans=n; while(low<=high){int mid= low+(high-low)/2;if( arr[mid]>=x ){ans=mid;high=mid-1;}else{low=mid+1;}} return ans; } public static int lower_boundlist(ArrayList<Integer> list,int n,int x){ //first ele>=x ka idx int low=0,high=n-1;int ans=n; while(low<=high){int mid= low+(high-low)/2;if( list.get(mid)>=x ){ans=mid;high=mid-1;}else{low=mid+1;}} return ans; } public static int upper_bound(int [] arr,int n,int x){ //first ele>x ka idx int low=0,high=n-1;int ans=n; while(low<=high){int mid= low+(high-low)/2;if( arr[mid]<=x ){low=mid+1;}else{ans=mid;high=mid-1;}} return ans; } public static void parr(int [] arr){for(int i=0;i<arr.length;i++){pw.print(arr[i]+" ");}} public static void parr(long [] arr){for(int i=0;i<arr.length;i++){pw.print(arr[i]+" ");}} public static void plist(ArrayList<Integer> list){for(int i=0;i<list.size();i++){pw.print(list.get(i)+" ");}} public static void pllist(ArrayList<Long> list){for(int i=0;i<list.size();i++){pw.print(list.get(i)+" ");}} // int [] arr=sc.intArr(a,b,n); <b static void solve() throws Exception{ int n = sc.nextInt(),l=sc.nextInt(),r=sc.nextInt(); // if( r-l+1 < n ){ // pw.println("NO"); // return; // } int [] arr= new int [n]; for(int i=1;i<=n;i++){ if(i==1){ arr[i-1]= l; }else{ if(l%i==0){ arr[i-1]=l; }else{ if( (l + (i-(l%i))) <=r ){ arr[i-1]=l+(i-(l%i)); }else{ pw.println("NO"); return; } } } } pw.println("YES"); parr(arr); pw.println(); } public static void main(String[] args) throws Exception{ try { System.setIn(new FileInputStream("input.txt")); System.setOut(new PrintStream(new FileOutputStream("output.txt"))); } catch (Exception e) { System.err.println("Error"); } sc= new FastReader(); pw = new PrintWriter(System.out); int tc=1; tc=sc.nextInt(); for(int i=1;i<=tc;i++) { // pw.printf("Case #%d: ", i); solve(); } pw.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 8
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
02ea007d8cfb68b798707e2ac70022dd
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.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Random; import java.util.HashSet; import java.util.HashMap; import java.util.StringTokenizer; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public 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()); } double nextDouble() { return Double.parseDouble(next()); } } 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 int highestPowerof2(int num) { num |= num >> 1; num |= num >> 2; num |= num >> 4; num |= num >> 8; num |= num >> 16; return num ^ (num >> 1); } public static void main (String[] args) throws java.lang.Exception { FastScanner fs=new FastScanner(); PrintWriter out=new PrintWriter(System.out); int t=fs.nextInt(); while(t-->0) { int n =fs.nextInt(); int l=fs.nextInt(); int r=fs.nextInt(); ArrayList<Integer> ali=new ArrayList<>(); int breaker=0; for(int i=1;i<=n ;i++) { if(l%i==0) { ali.add(l); } else{ int ceil=(l+i-1)/i; ceil*=i; if(ceil<=r) { ali.add(ceil); } else { breaker=1; break; } } } if(breaker==1) { out.println("NO"); continue; } if(ali.size()==n) { out.println("YES"); for(int x:ali) { out.print(x+" "); } out.println(); } else { out.println("NO"); } } 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 8
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
ed36d2f67b19b6837ef514054c2a33e1
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 final class Codeforces2 { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0){ long n = sc.nextLong(); long l =sc.nextLong(); long r = sc.nextLong(); String ans = "YES"; long arr[] = new long[(int)n+1]; for(int i=1;i<=n;i++){ long min = l/i; if(l%i != 0){ min++; } if((long)i*min <= r){ arr[i] = (long)i*min; } else { ans = "NO"; break; } } if(ans.equals("YES")){ System.out.println("YES"); for(int i=1;i<=n;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 8
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
518d513e0d26e89398f0d53af70bbdb0
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 C { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); outer: for (int oo = 0; oo < t; oo++) { int n = sc.nextInt(); long l = sc.nextInt(); long r = sc.nextInt(); long[] res = new long[n + 1]; for (int i = 1; i <= n; i++) { long q = l; if (q % i != 0) q = l + (i - (l % i)); if (q > r) { out.println("NO"); continue outer; } res[i] = q; } out.println("YES"); for (int i = 1; i <= n; i++) { out.print(res[i] + " "); } out.println(); } out.close(); } 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 8
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
887a010b11f3c891e2e7b16e24b8f745
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 { StringBuilder s1=new StringBuilder(); public static void main(String[] args) throws IOException { Scanner sc =new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t=1; t = sc.nextInt(); w:while (t-- > 0) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[] ans = new int[n]; for(int i = n-1; i >= 0; i--){ if(r/(i + 1) * (i + 1) < l){ pw.println("NO"); continue w; } ans[i] = r/(i+1) * (i+1); } pw.println("YES"); for(int x : ans) pw.print(x + " "); pw.println(); } pw.flush(); } static class Scanner { BufferedReader br; StringTokenizer st; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public Scanner(FileReader f) { br = new BufferedReader(f); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public int[] nextIntArr(int n) throws IOException { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = Integer.parseInt(next()); } return arr; } } }
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 8
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
86685ae17f358f660ed8817b1d897744
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 { StringBuilder s1=new StringBuilder(); public static void main(String[] args) throws IOException { Scanner sc =new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t=1; t = sc.nextInt(); w:while (t-- > 0) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[] ans = new int[n]; for(int i = n-1; i >= 0; i--){ if(countDivisibles(l, r, i + 1) <= 0){ pw.println("NO"); continue w; } ans[i] = r/(i+1) * (i+1); } pw.println("YES"); for(int x : ans) pw.print(x + " "); pw.println(); } pw.flush(); } static int countDivisibles(int A, int B, int M) { // Add 1 explicitly as A is divisible by M if (A % M == 0) return (B / M) - (A / M) + 1; // A is not divisible by M return (B / M) - (A / M); } private static int help(int n, int l, int r) { for(int i = r; i >= l; i--){ if(i%n ==0) return i; } return -1; } static class Scanner { BufferedReader br; StringTokenizer st; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public Scanner(FileReader f) { br = new BufferedReader(f); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public int[] nextIntArr(int n) throws IOException { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = Integer.parseInt(next()); } return arr; } } }
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 8
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
ae2d9891acd61b5c0ee1129be10279b3
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.util.Scanner; public class C { 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(); boolean check=true; // ArrayList<Integer> arr=new ArrayList<Integer>(); int arr[]=new int[n+1]; for(int i=1;i<=n;++i) { int p=l%i; if(p==0) { arr[i]=l; } else { arr[i]=l+i-p; if(arr[i]>r) { check=false; break; } } } if(n==1) { System.out.println("YES"); System.out.println(l); continue; } if(check) { System.out.println("YES"); for(int i=1;i<=n;++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 8
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
139af477e9d79707a66786c4a25080b9
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 { public static void main(String args[]) throws Exception { BufferedReader inp = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(inp.readLine()); while (t > 0) { long[] arr = Arrays.stream(inp.readLine().split("\\s+")).mapToLong(Long::parseLong).toArray(); long n = arr[0], l = arr[1], r = arr[2]; List<Long> ls = new ArrayList<>(); int i = 1; long max = 0; while (i <= n) { long a = l % (i); if (a == 0) { ls.add(l); max = Math.max(max, l); } else { long h = l + i - (l % (i)); ls.add(h); max = Math.max(max, h); } i++; } if (max > r) System.out.println("NO"); else { System.out.println("YES"); for (long k : ls) System.out.print(k + " "); 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 8
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
d441e6350378a1875b624226b479ff16
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 { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int test = in.nextInt(); for(int t = 1;t<=test;t++){ int n = in.nextInt(),l = in.nextInt(),r = in.nextInt(); StringBuilder sb = new StringBuilder(); boolean flag = true; for(int i = 1;i<=n;i++){ int a = r - (r %i); if(a<l){ flag = false; break; } else { sb.append(a+" "); } } if(flag){ pw.println("YES"); pw.println(sb); } else { pw.println("NO"); } } pw.close(); } public static int gcd(int a, int b) { if(b == 0) return a; else return gcd(b,a%b); } static void debug(Object... obj) { System.err.println(Arrays.deepToString(obj)); } }
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 8
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
1c2411bd947d541d1ba1653d028bb1e7
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 { public static void main(String[] args) throws IOException { Reader sc = new Reader(); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); List<Integer> list = new ArrayList<>(); int temp = l; boolean possible = true; for(int i = 0;i < n;i++) { if(l % (i + 1) == 0) { if(l <= r) list.add(l); else possible = false; } else { l += ((i + 1) - (l % (i + 1))); if(l <= r) list.add(l); else possible = false; } l = temp; } if(possible) { out.println("YES"); for(int i = 0;i < list.size();i++) out.print(list.get(i) + " "); out.println(); } else out.println("NO"); } out.flush(); } static int[] sort(int[] arr,int n) { List<Integer> list = new ArrayList<>(); 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); return arr; } static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } static int isPrime(int n) { if(n < 2) return 0; if(n < 4) return 1; if((n % 2) == 0 || (n % 3) == 0) return 0; for(int i = 5; (i * i) <= n; i += 6) if((n % i) == 0 || (n % (i + 2)) == 0) return 0; return 1; } static class Reader { BufferedReader br; StringTokenizer st; public Reader() { 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; } } } // ********************* Custom Pair Class ********************* //class Pair implements Comparable<Pair> { // int a,b; // public Pair(int a,int b) { // this.a = a; // this.b = b; // } // @Override // public int compareTo(Pair other) { //// if(this.b == other.b) //// return Integer.compare(this.a,other.a); // return Integer.compare(other.b,this.b); // } //} // ****************** Segment Tree ****************** //public class SegmentTreeNode { // public SegmentTreeNode left; // public SegmentTreeNode right; // public int Start; // public int End; // public int Sum; // public SegmentTreeNode(int start, int end) { // Start = start; // End = end; // Sum = 0; // } //} //public SegmentTreeNode buildTree(int start, int end) { // if(start > end) // return null; // SegmentTreeNode node = new SegmentTreeNode(start, end); // if(start == end) // return node; // int mid = start + (end - start) / 2; // node.left = buildTree(start, mid); // node.right = buildTree(mid + 1, end); // return node; //} //public void update(SegmentTreeNode node, int index) { // if(node == null) // return; // if(node.Start == index && node.End == index) { // node.Sum += 1; // return; // } // int mid = node.Start + (node.End - node.Start) / 2; // if(index <= mid) // update(node.left, index); // else // update(node.right, index); // node.Sum = node.left.Sum + node.right.Sum; //} //public int SumRange(SegmentTreeNode root, int start, int end) { // if(root == null || start > end) // return 0; // if(root.Start == start && root.End == end) // return root.Sum; // int mid = root.Start + (root.End - root.Start) / 2; // if(end <= mid) // return SumRange(root.left, start, end); // else if(start > mid) // return SumRange(root.right, start, end); // return SumRange(root.left, start, mid) + SumRange(root.right, mid + 1, end); //}
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 8
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
a26fc43fe4c4d68d5b3d262834f939a8
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 { public static void main(String[] args) throws IOException { //Scanner in = new Scanner(System.in); FastReader in = new FastReader(System.in); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); int t = in.nextInt(); rana: for (int tt = 0; tt < t; tt++) { int n = in.nextInt(); int l = in.nextInt(); int r = in.nextInt(); int[] ans = new int[n + 1]; int x; for (int i = 1; i <= n; i++) { if (l % i == 0) x = l; else x = l + (i - l % i); if (x < l || x > r) { pw.println("NO"); continue rana; } else ans[i] = x; } //debug(ans); pw.println("YES"); for (int i = 1; i <= n; i++) pw.print(ans[i] + " "); pw.println(); } pw.close(); } static class Pair implements Comparable<Pair> { int a, b; Pair(int a, int b) { this.a = a; this.b = b; } @Override public int compareTo(Pair o) { return Integer.compare(this.b, o.b); } } public static void Sort(int[] a) { List<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 debug(Object... obj) { System.err.println(Arrays.deepToString(obj)); } static long lcm(long a, long b) { return (a / gcd(a, b)) * b; } static long gcd(long a, long b) { if (b == 0) return a; else return gcd(b, a % b); } static class FastReader { InputStream is; private byte[] inbuf = new byte[1024]; private int lenbuf = 0, ptrbuf = 0; public FastReader(InputStream is) { this.is = is; } public int readByte() { if (lenbuf == -1) throw new InputMismatchException(); if (ptrbuf >= lenbuf) { ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return -1; } return inbuf[ptrbuf++]; } public boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } public int skip() { int b; while ((b = readByte()) != -1 && isSpaceChar(b)) ; return b; } public String next() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!(isSpaceChar(b))) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public String nextLine() { int c = skip(); StringBuilder sb = new StringBuilder(); while (!isEndOfLine(c)) { sb.appendCodePoint(c); c = readByte(); } return sb.toString(); } public int nextInt() { int num = 0, b; boolean minus = false; while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ; if (b == '-') { minus = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { num = (num << 3) + (num << 1) + (b - '0'); } else { return minus ? -num : num; } b = readByte(); } } public long nextLong() { long num = 0; int b; boolean minus = false; while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ; if (b == '-') { minus = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { num = (num << 3) + (num << 1) + (b - '0'); } else { return minus ? -num : num; } b = readByte(); } } public double nextDouble() { return Double.parseDouble(next()); } public char[] next(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while (p < n && !(isSpaceChar(b))) { buf[p++] = (char) b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } public char readChar() { return (char) skip(); } public int[] readArray(int n) { int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = nextInt(); return arr; } } }
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 8
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
cd14e58e09d4a1299364d6ca0a3671a7
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 DiferentNOD { 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(); int count = 0; int[] array = new int[n]; for (int i = 1; i <= n; i++) { int x = l % i; int y = r % i; if (r - l + 1 > i || y < x || x == 0) { if (x == 0) array[i - 1] = l; else array[i - 1] = l + i - x; } else { System.out.println("NO"); count++; break; } } if (count == 0) { System.out.println("YES"); for (int res = 0; res < array.length; res++) { System.out.print(array[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 8
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
f3a352c9c90c38b0ec2b3498ca4ee9bb
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.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.Buffer; import java.util.*; public class Main2 { public static void main(String[] args) throws IOException, InterruptedException { Scanner sc = new Scanner(System.in); int testCases = sc.nextInt(); while (testCases -- > 0) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[] array = new int[n + 1]; boolean can = true; for(int i = 1; i <= n; i++) { int number = (l / i); int put = number * i; if(l % i != 0) put += i; if(put > r) can = false; array[i] = put; } if(can == false) System.out.println("no"); else { System.out.println("YES"); for(int i =1; i <= n; i++) { if(i != 1) System.out.print(" "); System.out.print(array[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 8
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
19ce37f2c02d954265f261ccf1f53908
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.util.Arrays; import java.util.Scanner; public class GCD { public static void main(String args[]) { Scanner p = new Scanner(System.in); int y = p.nextInt(); for(int ia=0;ia<y;ia++) { int n = p.nextInt(); int l = p.nextInt(); int r = p.nextInt(); boolean q = true; int[] arr = new int[n]; if(r == l) { int i = 0; while(i<n && q == true) { if(r%(i+1)!=0) { q = false; } else { i = i + 1; } } if(q == false) { System.out.println("NO"); } else { System.out.println("YES"); for(i =0;i<n;i++) { System.out.print(r +" "); } System.out.println(); } } else { int i = 1; while(i<=n && q == true) { int h = l%i; if( h == 0) { arr[i-1] = l; } else if(i-h<=r-l) { arr[i-1] = l + i - h; } else { q = false; } i = i + 1; } if(q == false) { System.out.println("NO"); } else { System.out.println("YES"); for(int iaa=0;iaa<n;iaa++) { System.out.print(arr[iaa] + " "); } 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 8
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
356aac6e7dd9abfae02c15b1322bce15
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 CF808B { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int left = sc.nextInt(); int right = sc.nextInt(); int[] ans = new int[n]; boolean flag = true; for(int i=1; i<=n; i++){ int last = (left )%i; if(last == 0){ ans[i-1] = left; continue; } if(left+ i-last >right){ System.out.println("NO"); flag = false; break; }else { ans[i-1] = left+i-last; } } if(flag){ System.out.println("YES"); for(int i=0; i<n ;i++){ if(i==n-1){ System.out.println(ans[i]); }else{ System.out.println(ans[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 8
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
d106858b7ec0aa3879ab6fea17643841
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.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.security.KeyPair; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Stack; import java.util.TreeMap; /* Name of the class has to be "Main" only if the class is public. */ public class temp { abstract class sort implements Comparator<ArrayList<Integer>>{ @Override public int compare(ArrayList<Integer> a,ArrayList<Integer> b) { return a.get(0)-b.get(0); } } private static Comparator sort; public static void main (String[] args) throws Exception { FastScanner sc= new FastScanner(); int tt = sc.nextInt(); while(tt-->0){ int n=sc.nextInt(); int l=sc.nextInt(); int r=sc.nextInt(); ArrayList<Integer> list=new ArrayList<>(); list.add(l); for(int i=2;i<=n;i++) { if(l%i==0) { list.add(l); }else { int res=l/i; int temp=(res+1)*i; if(temp<=r) list.add(temp); } } if(list.size()==n) { System.out.println("YES"); for(int i:list) System.out.print(i+" "); System.out.println(); continue; } System.out.println("NO"); } } public static int fac(int n) { if(n==0) return 1; return n*fac(n-1); } public static boolean palin(String res) { StringBuilder sb=new StringBuilder(res); String temp=sb.reverse().toString(); return(temp.equals(res)); } 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; } public static int gcd(int a, int b) { if(a > b) a = (a+b)-(b=a); if(a == 0L) return b; return gcd(b%a, a); } public static ArrayList<Integer> findDiv(int N) { //gens all divisors of N ArrayList<Integer> ls1 = new ArrayList<Integer>(); ArrayList<Integer> ls2 = new ArrayList<Integer>(); for(int i=1; i <= (int)(Math.sqrt(N)+0.00000001); i++) if(N%i == 0) { ls1.add(i); ls2.add(N/i); } Collections.reverse(ls2); for(int b: ls2) if(b != ls1.get(ls1.size()-1)) ls1.add(b); return ls1; } public static void sort(int[] arr) { //because Arrays.sort() uses quicksort which is dumb //Collections.sort() uses merge sort ArrayList<Integer> ls = new ArrayList<Integer>(); 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 long power(long x, long y, long p) { //0^0 = 1 long res = 1L; x = x%p; while(y > 0) { if((y&1)==1) res = (res*x)%p; y >>= 1; x = (x*x)%p; } return res; } static class FastScanner { //I don't understand how this works lmao private int BS = 1 << 16; private char NC = (char) 0; private byte[] buf = new byte[BS]; private int bId = 0, size = 0; private char c = NC; private double cnt = 1; private BufferedInputStream in; public FastScanner() { in = new BufferedInputStream(System.in, BS); } public FastScanner(String s) { try { in = new BufferedInputStream(new FileInputStream(new File(s)), BS); } catch (Exception e) { in = new BufferedInputStream(System.in, BS); } } private char getChar() { 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 int[] nextInts(int N) { int[] res = new int[N]; for (int i = 0; i < N; i++) { res[i] = (int) nextLong(); } return res; } public long[] nextLongs(int N) { long[] res = new long[N]; for (int i = 0; i < N; i++) { res[i] = nextLong(); } return res; } public long nextLong() { cnt = 1; boolean neg = false; if (c == NC) c = getChar(); for (; (c < '0' || c > '9'); c = getChar()) { if (c == '-') neg = true; } long res = 0; for (; c >= '0' && c <= '9'; c = getChar()) { res = (res << 3) + (res << 1) + c - '0'; cnt *= 10; } return neg ? -res : res; } public double nextDouble() { double cur = nextLong(); return c != '.' ? cur : cur + nextLong() / cnt; } public double[] nextDoubles(int N) { double[] res = new double[N]; for (int i = 0; i < N; i++) { res[i] = nextDouble(); } return res; } public String next() { StringBuilder res = new StringBuilder(); while (c <= 32) c = getChar(); while (c > 32) { res.append(c); c = getChar(); } return res.toString(); } public String nextLine() { StringBuilder res = new StringBuilder(); while (c <= 32) c = getChar(); while (c != '\n') { res.append(c); c = getChar(); } return res.toString(); } public boolean hasNext() { if (c > 32) return true; while (true) { c = getChar(); if (c == NC) return false; else if (c > 32) 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 8
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
918b2be69391285005ef3db86fec9d8d
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 _1708B { 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(); Vector<Long> ans = new Vector<>(); for (int i = 1; i <= n; i++) { long num = ((long)Math.ceil(((double) l / i))) * i; if (num >= l && num <= r) ans.add(num); } if (ans.size() == n) { System.out.println("YES"); for (Long i : ans) System.out.print(i + " "); } else System.out.print("NO"); System.out.println(); } } public static int gcd(int a, int b) { return (a == 0) ? b : gcd(b % a, a); } static int power(int x, int y) { int ans = 1; while (y > 0) { if ((y & 1) != 0) ans *= x; y = y >> 1; x *= x; } return ans; } public static List<Integer> sieve(int n) { List<Integer> primes = new LinkedList<>(); boolean[] composite = new boolean[n + 1]; for (int i = 2; i * i <= n; i++) for (int j = i * i; j <= n && !composite[i]; j += i) composite[j] = true; for (int j = 2; j < composite.length; j++) if (!composite[j]) primes.add(j); return primes; } }
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 8
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
237d2422c2200aa466f2838c5eb135aa
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.ArrayList; import java.util.Scanner; public class DifferncceGCD { 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(); ArrayList<Integer> al=new ArrayList<>(); al.add(l); int count=1; for(int i=2;i<=n;i++){ if(l%i==0){ al.add(l); count++; }else{ int j=l/i; j=(j+1)*i; if(j<=r){ al.add(j); count++; }else{ break; } } } if(count==n){ System.out.println("YES"); for(int i:al){ System.out.print(i+" "); } }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 8
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
82faa63603b6c58cfaef492206f383ea
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 differenceGCD { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int testCases=sc.nextInt(); for (int i=0;i<testCases;i++){ int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[] out = new int[n]; boolean valid=true; for(int p=0;p<n;p++){ if(l%(p+1)==0){ out[p]=l; }else{ out[p]=l+(p+1-(l%(p+1))); } if(out[p]>r){ valid=false; break; } } if(valid){ System.out.println("YES"); for(int p=0;p<n;p++){ System.out.print(out[p]+" "); } 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 8
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
ac57d05ce82c6bd08677af63cb89993e
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 DiffGCDs { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numTestCases = sc.nextInt(); for(int i=0; i<numTestCases; i++) { processGCDList(sc.nextInt(), sc.nextInt(), sc.nextInt()); } } public static int GCD(int num1, int num2) { int gcd = 1; int smallerInt = Math.min(num1, num2); for(int i=1; i <= smallerInt; i++) { if(num1 % i == 0 && num2 % i == 0) gcd = i; } return gcd; } public static int[] fillGCDs(int n, int low, int high) { int[] array = new int[n]; for(int i=0; i<n; i++) { array[i] = low + (i + 1 - low % (i + 1)); if(low % (i + 1) == 0) array[i] -= i + 1; if(array[i] > high) return new int[]{0}; } return array; } public static void processGCDList(int n, int low, int high) { int[] arr = fillGCDs(n, low, high); if(arr[0] == 0 && arr.length == 1) { System.out.println("NO"); } else { System.out.println("YES"); for(int curr : arr) System.out.print(curr + " "); 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 8
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
0b885c2a11f06a8445c813001534e5bd
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.ArrayList; import java.util.List; import java.util.Scanner; public class DifferenceOfGCDs { public static void main(String[] args) { Scanner sc = new Scanner(System.in); 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<>(); int flag = 0; list.add(l); for(int i = 2;i<=n;i++){ if(l%i==0){ list.add(l); } else{ int j = l/i; int kk = (j+1)*i; if(kk<=r) { list.add(kk); } else{ break; } } } if(list.size() == n){ System.out.println("YES"); for(int e: list){ System.out.print(e+" "); } 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 8
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
59368c44cb286bf353ff9fd24db3ef56
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 { public static String concat(String s1, String s2) { return new StringBuilder(s1).append(s2).toString(); } public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter o = new PrintWriter(System.out); int t1 = sc.nextInt(); while (t1-- > 0) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); boolean aa = false; long a [] = new long[n]; for (int i = 1;i<=n;i++) { if (((l-1)/i+1)*i<=r) { a[i-1] = ((l-1)/i+1)*i; }else { aa = true; o.println("NO"); break; } } if (!aa) { o.println("YES"); for (int i = 0;i<n;i++) { o.print(a[i] + " "); } o.println(); } } o.close(); } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public double nextDouble() throws IOException { String x = next(); StringBuilder sb = new StringBuilder("0"); double res = 0, f = 1; boolean dec = false, neg = false; int start = 0; if (x.charAt(0) == '-') { neg = true; start++; } for (int i = start; i < x.length(); i++) if (x.charAt(i) == '.') { res = Long.parseLong(sb.toString()); sb = new StringBuilder("0"); dec = true; } else { sb.append(x.charAt(i)); if (dec) f *= 10; } res += Long.parseLong(sb.toString()) / f; return res * (neg ? -1 : 1); } public boolean ready() throws IOException { return br.ready(); } Long[] readArray(int n) throws IOException { Long[] a = new Long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); 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 8
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
a79708ea51959c9c48db2b49e85c7b96
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_Bajrang_Bali * @Har_Har_Mahadev */ /* Author: Sanat Kumar Dubey (sanat04) * File: B.java */ import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class B { static long gcd(long a, long b) { if (b > a) { return gcd(b, a); } if (b == 0) { return a; } return gcd(b, a % b); } 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+5]; boolean check=true; for (int i = 1; i <=n ; i++) { arr[i]=((l-1)/i+1)*i; check=check && arr[i]<=r; } if(check){ System.out.println("YES"); for (int i = 1; i <=n; 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 8
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
9e0e1fbd4285892fda0ff8b3a434d97b
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.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Queue; import java.util.StringTokenizer; import java.util.TreeSet; public class B { static ArrayList<Integer>adj[]; static int[]vis; static ArrayList<String>[]arr; static HashMap<String, Integer>dp; static HashSet<String>dat; static int c,n; public static void main(String[]args) throws IOException { // Scanner sc=new Scanner("files.in"); Scanner sc=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); int t=sc.nextInt(); a:while(t-->0) { int n=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt(); // long vl=1l*l*n; // if(r-l+1<n) {out.println("NO");continue;} HashSet<Integer>hs=new HashSet<Integer>(); int[]ans=new int[n+1]; for(int i=1;i<=n;i++) { int v = (l-1)/i+1; v*=i; // while(hs.contains(v)&&v<=r) { // v+=i; // } if(v>r) {out.println("NO");continue a;} ans[i]=v; // hs.add(v); } out.println("YES"); for(int i=1;i<=n;i++)out.print(ans[i]+" "); out.println(); } out.close(); } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s){ br = new BufferedReader(new InputStreamReader(s));} public Scanner(String s) throws IOException{ br=new BufferedReader(new FileReader(new File(s))); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public boolean hasNext() {return st.hasMoreTokens();} public int nextInt() throws IOException {return Integer.parseInt(next());} public double nextDouble() throws IOException {return Double.parseDouble(next());} public long nextLong() throws IOException {return Long.parseLong(next());} public String nextLine() throws IOException {return br.readLine();} public boolean ready() throws IOException {return br.ready(); } } }
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 8
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
37d48a2cd1343f2ea64cc75e57eaa9c0
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 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int l = sc.nextInt(), r = sc.nextInt(); ArrayList<Integer> div = new ArrayList<>(); for (int i = 1; i <= n; i++) { if (((l-1)/i + 1) * i <= r) div.add(((l-1)/i + 1) * i); } if (div.size() == n) { out.println("YES"); for (long x : div) out.print(x + " "); out.println(); } else out.println("NO"); } out.close(); } static int bs(int[] a, int x) { int l = 0, r = a.length-1; int ans = -1; while (l <= r) { int mid = (l+r)/2; if (a[mid] == x) { ans = mid; break; } else if (a[mid] > x) r = mid-1; else l = mid+1; } return ans; } static final Random random = new Random(); static void shuffleSort(int[] a) { int n = a.length; for (int i = 0; i < n; i++) { int r = random.nextInt(n), temp = a[r]; a[r] = a[i]; a[i] = temp; } Arrays.sort(a); } static void shuffleSort(long[] a) { int n = a.length; for (int i = 0; i < n; i++) { int r = random.nextInt(n); long temp = a[r]; a[r] = a[i]; a[i] = temp; } Arrays.sort(a); } 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 Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s){ br = new BufferedReader(new InputStreamReader(s));} public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException {return Integer.parseInt(next());} public long nextLong() throws IOException {return Long.parseLong(next());} public String nextLine() throws IOException {return br.readLine();} public double nextDouble() throws IOException { String x = next(); StringBuilder sb = new StringBuilder("0"); double res = 0, f = 1; boolean dec = false, neg = false; int start = 0; if(x.charAt(0) == '-') { neg = true; start++; } for(int i = start; i < x.length(); i++) if(x.charAt(i) == '.') { res = Long.parseLong(sb.toString()); sb = new StringBuilder("0"); dec = true; } else { sb.append(x.charAt(i)); if(dec) f *= 10; } res += Long.parseLong(sb.toString()) / f; return res * (neg?-1:1); } public boolean ready() throws IOException {return br.ready();} int[] readArray(int n) throws IOException { int[] a=new int[n]; for (int i=0; i<n; i++) a[i] = nextInt(); 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 8
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
8af67585450945481a43443728ba0ad8
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.PrintWriter; import java.lang.*; import java.io.IOException; import java.io.InputStreamReader; import java.security.spec.RSAOtherPrimeInfo; import java.util.*; public class First { static long mod = (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 { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } static void sort(long[] arr) { ArrayList<Long> a = new ArrayList<>(); for (long i : arr) { a.add(i); } Collections.sort(a); for (int i = 0; i < a.size(); i++) { arr[i] = a.get(i); } } static long highestPowerof2(long x) { x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; return x ^ (x >> 1); } public static long fact(long number) { if (number == 0 || number == 1) { return 1; } else { return number * fact(number - 1); } } public static ArrayList<Long> primeFactors(long n) { ArrayList<Long> arr = new ArrayList<>(); long count = 0; while (n % 2 == 0) { arr.add(2l); n /= 2; } for (long i = 3; i <= Math.sqrt(n); i += 2) { while (n % i == 0) { arr.add(i); n /= i; } } if (n > 2) arr.add(n); return arr; } static public long[] prime(long number) { long n = number; long count = 0; long even = 0; for (long i = 2; i <= n / i; i++) { while (n % i == 0) { if (i % 2 == 1) { count++; } else { even++; } n /= i; } } if (n > 1) { if (n % 2 == 1) { count++; } else { even++; } } return new long[]{even, count}; } static void swap(int[] arr, int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } static int search(ArrayList<Integer> arr, int tar) { int low = 0, hi = arr.size() - 1; int ans = -1; while (low <= hi) { int mid = (low + hi) / 2; if (arr.get(mid) > tar) { ans = arr.get(mid); hi = mid - 1; } else { low = mid + 1; } } return ans; } static long gcd(long a, long b) { // if b=0, a is the GCD if (b == 0) return a; else return gcd(b, a % b); } 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; } static int get(long[] arr, long tar){ int ans = -1; int l = 0; int h = arr.length-1; while(l <= h){ int mid = l + (h-l)/2; if(arr[mid] <= tar){ ans = mid; l = mid+1; }else{ h = mid-1; } } return ans; } public static long maxSum(long arr[],int k) { int n = arr.length; if (n < k || k < 0) { return Long.MAX_VALUE; } long res = 0; for (int i=0; i<k; i++) res += arr[i]; 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 get(ArrayList<long[]> arr, long tar){ int ans = -1; int l = 0; int h = arr.size()-1; while(l <= h){ int mid = (l+h)/2; if(arr.get(mid)[0] > tar){ ans = mid; h = mid-1; }else{ l = mid+1; } } return ans; } static long closestMultiple(long n, long x) { if(x>n) return x; n = n + x/2; n = n - (n%x); return n; } static void print_Array(int[] arr){ for(int i: arr){ System.out.print(i+" "); } System.out.println(); } public static void main(String[] args) throws Exception { FastReader sc = new FastReader(); int t = sc.nextInt(); while(t-- > 0){ long n = sc.nextLong(); long l = sc.nextLong(); long r = sc.nextLong(); HashSet<Long> set = new HashSet<>(); boolean find = true; StringBuilder ans = new StringBuilder(); ans.append(l).append(" "); long pre = l; for(int i = 2; i<= n; i++){ long get = 0; if(pre%i == 0){ get = pre; }else{ get= ((pre)/i)*i+ i; if(get > r){ get -= i; } } if(get < l || get > r){ find = false; break; }else{ ans.append(get).append(" "); } } if(find){ System.out.println("YES"); System.out.println(ans); }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 8
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
2017d2231e2dc8b3deaf262168eefe55
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.HashSet; import java.util.StringTokenizer; public class Main { static Main2 admin = new Main2(); public static void main(String[] args) { admin.start(); } } class Main2 { //---------------------------------INPUT READER-----------------------------------------// public BufferedReader br; StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine());} catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int ni() { return Integer.parseInt(next()); } long nl() { return Long.parseLong(next()); } double nd() { return Double.parseDouble(next()); } String ns() { return next(); } int[] na(long n) {int[]ret=new int[(int)n]; for(int i=0;i<n;i++) ret[i]=ni(); return ret;} long[] nal(long n) {long[]ret=new long[(int)n]; for(int i=0;i<n;i++) ret[i]=nl(); return ret;} Integer[] nA(long n) {Integer[]ret=new Integer[(int)n]; for(int i=0;i<n;i++) ret[i]=ni(); return ret;} Long[] nAl(long n) {Long[]ret=new Long[(int)n]; for(int i=0;i<n;i++) ret[i]=nl(); return ret;} //--------------------------------------PRINTER------------------------------------------// PrintWriter w; void p(int i) {w.println(i);} void p(long l) {w.println(l);} void p(double d) {w.println(d);} void p(String s) { w.println(s);} void pr(int i) {w.print(i);} void pr(long l) {w.print(l);} void pr(double d) {w.print(d);} void pr(String s) { w.print(s);} void pl() {w.println();} //--------------------------------------VARIABLES-----------------------------------------// long lma = Long.MAX_VALUE, lmi = Long.MIN_VALUE; int ima = Integer.MAX_VALUE, imi = Integer.MIN_VALUE; long mod = 1000000007; { w = new PrintWriter(System.out); br = new BufferedReader(new InputStreamReader(System.in)); try {if(new File(System.getProperty("user.dir")).getName().equals("LOCAL")) { w = new PrintWriter(new OutputStreamWriter(new FileOutputStream("output.txt"))); br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));} } catch (Exception ignore) { } } //----------------------START---------------------// void start() { int t = ni(); while(t-- > 0) solve(); w.close(); } long start(long i, long l) { long q = l/i; if(i*q >= l) return i*q; else return i*(q+1); } long end (long i, long r) { long q = r/i; return i*q; } void solve() { int n = ni(); long l = nl(), r = nl(); // HashSet<Long> used = new HashSet<>(); long[] ans = new long[n+1]; for(int i = n; i > 0; i--) { long end = end(i, r); boolean f = false; for(long j = end; j >= l; j-=i) { ans[i] = j; f = true; break; } if(!f) { p("NO"); return; } } p("YES"); for(int i = 1; i <= n; i++) pr(ans[i]+" "); pl(); } }
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 8
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
131e21f42476f5b5b3723503197206cc
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 {//Roof Construction - A. Ancient Civilization static TreeSet<String> tSet; static PrintWriter pw; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int l=sc.nextInt(); int r=sc.nextInt(); ArrayList<Integer> arr=new ArrayList<>(); for (int i = 1; i <= n; i++) { int fac=(int)Math.ceil((l+0.0)/i); if((fac*i)>=l &&(fac*i)<=r) { arr.add(fac*i); } } boolean flag=false; for(int i:arr) { if(arr.size()==n) { if(!flag) { pw.println("yes"); flag=true; } pw.print(i+" "); } else { pw.print("no"); break; } } pw.println(); } pw.close(); pw.flush(); } public static long convert(Long x) { int c=0; int res=0; while(x!=0) { if(x%10 ==1 ) { res+=Math.pow(2, c); } x/=10; c++; } return res; } public static int dfsOnAdjacencyList(ArrayList<Integer>[] graph, int curr, boolean[] vis, int m, int conscats, int[] cats) { // same DFS code but a7la mn ellyfoo2 fel writing if (conscats > m) return 0; if (graph[curr].size() == 1 && curr != 1) { if (cats[curr] == 1) conscats++; else conscats = 0; if (conscats > m) return 0; return 1; } vis[curr] = true; if (cats[curr] == 1) conscats++; else conscats = 0; int res = 0; for (int x : graph[curr]) { if (!vis[x]) res += dfsOnAdjacencyList(graph, x, vis, m, conscats, cats); } return res; } public static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } public static int lcm(int a, int b) { return a * b / gcd(a, b); } public static long fac(long i) { long res = 1; while (i > 0) { res = res * i--; } return res; } public static long combination(long x, long y) { return 1l * (fac(x) / (fac(x - y) * fac(y))); } public static long permutation(long x, long y) { return combination(x, y) * fac(y); } static class Pair implements Comparable<Pair> { int x; int y; public Pair(int x, int y) { this.x = x; this.y = y; } public String toString() { return x + " " + y; } public int compareTo(Pair p) { if(this.x==p.x) return this.y-p.y; return this.x-p.x; } } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public double nextDouble() throws IOException { String x = next(); StringBuilder sb = new StringBuilder("0"); double res = 0, f = 1; boolean dec = false, neg = false; int start = 0; if (x.charAt(0) == '-') { neg = true; start++; } for (int i = start; i < x.length(); i++) if (x.charAt(i) == '.') { res = Long.parseLong(sb.toString()); sb = new StringBuilder("0"); dec = true; } else { sb.append(x.charAt(i)); if (dec) f *= 10; } res += Long.parseLong(sb.toString()) / f; return res * (neg ? -1 : 1); } public int[] nextIntArray(int n) throws IOException { int[] array = new int[n]; for (int i = 0; i < n; i++) { array[i] = nextInt(); } return array; } public Integer[] nextIntegerArray(int n) throws IOException { Integer[] array = new Integer[n]; for (int i = 0; i < n; i++) { array[i] = nextInt(); } return array; } public long[] nextlongArray(int n) throws IOException { long[] array = new long[n]; for (int i = 0; i < n; i++) { array[i] = nextLong(); } return array; } public Long[] nextLongArray(int n) throws IOException { Long[] array = new Long[n]; for (int i = 0; i < n; i++) { array[i] = nextLong(); } return array; } public char[] nextCharArray(int n) throws IOException { char[] array = new char[n]; String string = next(); for (int i = 0; i < n; i++) { array[i] = string.charAt(i); } return array; } public boolean ready() throws IOException { return br.ready(); } } }
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 8
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
5e225ae70065399a15ff650aad8108ea
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 habd { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int tc = sc.nextInt(); while(tc-->0){ int n = sc.nextInt(); long l = sc.nextLong(), r = sc.nextLong(); long[] arr = new long[n]; boolean ans = true; for(int i = 0; i<n; i++){ if((i + 1) * l <= r){ arr[i] = (i + 1) * l; }else{ long temp = (long) Math.ceil(l / (i + 1.0)); long x = (i + 1) * temp; if(x <= r && x >= l)arr[i] = x; else{ ans = false; break; } } } if(ans){ pw.println("YES"); for(long x: arr)pw.print(x + " "); pw.println(); }else pw.println("NO"); } pw.flush(); } static class SegmentTree{ long[] tree; int N; public SegmentTree(long[] arr){ N = arr.length; tree = new long[2*N - 1]; build(tree, arr); } public void build(long[] tree, long[] arr){ for(int i = N-1, j = 0; i<tree.length; i++, j++)tree[i] = arr[j]; for(int i = tree.length - 1, j = i - 1, k = N-2; k>=0; i -= 2, j-= 2, k--){ tree[k] = tree[i] + tree[j]; } } public void update(int idx, int val){ tree[idx + N - 2] = val; boolean f = true; int i = idx + N - 2; int j = i - 1; if(i % 2 != 0){ i++; j++; } for(int k = (tree.length - N - 1) - ((tree.length - 1 - i)/2); k>=0; ){ tree[k] = tree[i] + tree[j]; f = !f; i = k; j = k - 1; if(k % 2 != 0){ i++; j++; } k = (tree.length - N - 1) - ((tree.length - 1 - i)/2); } } } public static boolean isSorted(int[] arr){ boolean f = true; for(int i = 1; i<arr.length; i++){ if(arr[i] < arr[i - 1]){ f = false; break; } } return f; } public static int binary_Search(long key, long[] arr){ int low = 0; int high = arr.length; int mid = (low + high) / 2; while(low <= high){ mid = low + (high - low) / 2; if(arr[mid] == key)break; else if(arr[mid] > key) high = mid - 1; else low = mid + 1; } return mid; } public static int differences(int n, int test){ int changes = 0; while(test > 0){ if(test % 10 != n % 10)changes++; test/=10; n/=10; } return changes; } static int maxSubArraySum(int a[], int size) { int max_so_far = Integer.MIN_VALUE, max_ending_here = 0,start = 0, end = 0, s = 0; for (int i = 0; i < size; i++) { max_ending_here += a[i]; if (max_so_far < max_ending_here) { max_so_far = max_ending_here; start = s; end = i; } if (max_ending_here < 0) { max_ending_here = 0; s = i + 1; } } return start; } static int maxSubArraySum2(int a[], int size) { int max_so_far = Integer.MIN_VALUE, max_ending_here = 0,start = 0, end = 0, s = 0; for (int i = 0; i < size; i++) { max_ending_here += a[i]; if (max_so_far < max_ending_here) { max_so_far = max_ending_here; start = s; end = i; } if (max_ending_here < 0) { max_ending_here = 0; s = i + 1; } } return end; } public static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } public static class Pair implements Comparable<Pair>{ int x; int y; public Pair(int x, int y){ this.x = x; this.y = y; } public int compareTo(Pair x){ if(this.x == x.x)return this.y - x.y; return this.x - x.x; } public String toString(){ return "("+this.x + ", " + this.y + ")"; } } public static class Tuple implements Comparable<Tuple>{ long x; long y; long z; int idx; public Tuple(long x, long y, long z, int idx){ this.x = x; this.y = y; this.z = z; this.idx = idx; } public int compareTo(Tuple x){ return -1; } public String toString(){ return "("+this.x + ", " + this.y + ", " + this.z + ", " + this.idx + ")"; } } public static boolean isSubsequence(char[] arr, String s){ boolean ans = false; for(int i = 0, j = 0; i<arr.length; i++){ if(arr[i] == s.charAt(j)){ j++; } if(j == s.length()){ ans = true; break; } } return ans; } public static void sortIdx(long[]a,long[]idx) { mergesortidx(a, idx, 0, a.length-1); } static void mergesortidx(long[] arr,long[]idx,int b,int e) { if(b<e) { int m=b+(e-b)/2; mergesortidx(arr,idx,b,m); mergesortidx(arr,idx,m+1,e); mergeidx(arr,idx,b,m,e); } return; } static void mergeidx(long[] arr,long[]idx,int b,int m,int e) { int len1=m-b+1,len2=e-m; long[] l=new long[len1]; long[] lidx=new long[len1]; long[] r=new long[len2]; long[] ridx=new long[len2]; for(int i=0;i<len1;i++) { l[i]=arr[b+i]; lidx[i]=idx[b+i]; } for(int i=0;i<len2;i++) { r[i]=arr[m+1+i]; ridx[i]=idx[m+1+i]; } int i=0,j=0,k=b; while(i<len1 && j<len2) { if(l[i]<=r[j]) { arr[k++]=l[i++]; idx[k-1]=lidx[i-1]; } else { arr[k++]=r[j++]; idx[k-1]=ridx[j-1]; } } while(i<len1) { idx[k]=lidx[i]; arr[k++]=l[i++]; } while(j<len2) { idx[k]=ridx[j]; arr[k++]=r[j++]; } return; } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public Scanner(FileReader r) { br = new BufferedReader(r); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public double nextDouble() throws IOException { String x = next(); StringBuilder sb = new StringBuilder("0"); double res = 0, f = 1; boolean dec = false, neg = false; int start = 0; if (x.charAt(0) == '-') { neg = true; start++; } for (int i = start; i < x.length(); i++) if (x.charAt(i) == '.') { res = Long.parseLong(sb.toString()); sb = new StringBuilder("0"); dec = true; } else { sb.append(x.charAt(i)); if (dec) f *= 10; } res += Long.parseLong(sb.toString()) / f; return res * (neg ? -1 : 1); } public long[] nextlongArray(int n) throws IOException { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public Long[] nextLongArray(int n) throws IOException { Long[] a = new Long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public int[] nextIntArray(int n) throws IOException { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public Integer[] nextIntegerArray(int n) throws IOException { Integer[] a = new Integer[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public boolean ready() throws IOException { return br.ready(); } } }
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 8
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
7827938fa711ee2997eade5b2ce95f16
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){ Scanner sc = new Scanner(System.in); int t=sc.nextInt(); while(t--!=0){ //System.out.println("Dont"); int n=sc.nextInt(); int l=sc.nextInt(); int r=sc.nextInt(); //System.out.println("BYE"); int[] arr=new int[n]; boolean done=true; int rem=0; //int div=0; for(int i=0;i<n;i++){ rem=r%(i+1); // if(l>=(i+1)) // { // div=l/(i+1); // rem=((div+1)*(i+1))-l; // } // //rem=l%(i+1); // else{ // rem=(i+1)-l; // } //System.out.println("remainder for "+(i+1)+" = "+rem); if(r-rem>=l){ arr[i]=r-rem; } else{ done=false; break; } } if(done){ System.out.println("YES"); for(int i=0;i<n;i++){ System.out.print(arr[i]+" "); } System.out.println(); } else{ System.out.println("NO"); // System.out.println("HI"); } } } }
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 8
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
7c0daf6948d33d174ac2858417780897
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 { public static void main(String[] args)throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw=new PrintWriter(System.out); int t=Integer.parseInt(br.readLine()); while(t-->0) { String s[]=(br.readLine()).split(" "); int n=Integer.parseInt(s[0]); long l=Long.parseLong(s[1]); long r=Long.parseLong(s[2]); if((int)r<n) { pw.println("NO"); continue; } long ar[]=new long[n+1]; boolean flag=true; for(int i=2;i<=n;i++) { if(ar[i]!=0) { continue; } long i1=i; long x=1l; ArrayList<Integer> al=new ArrayList<>(); while((x*i1)<=n) { x*=i1; al.add((int)x); } if((r-(r%x))>=l) { long num=r-(r%x); for(int j=0;j<al.size();j++) { ar[al.get(j)]=num; } } else { flag=false; break; } } if(!flag) { pw.println("NO"); } else { pw.println("YES"); ar[1]=l; for(int i=1;i<=n;i++) { pw.print(ar[i]+" "); } pw.println(); } } pw.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 8
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
efe9116c0fcc343342abf5a6b96f0e0a
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 static java.lang.Math.*; public class Codeforces { public static PrintWriter out; public static Scanner sc; public static void main(String[] args) throws IOException { sc = new Scanner(System.in); out = new PrintWriter(System.out); int t = 1; t = sc.nextInt(); while(t-->0) solve(); out.flush(); out.close(); } public static void solve() throws IOException{ int n = sc.nextInt(); long l = sc.nextLong(); long r = sc.nextLong(); long[] arr = new long[n]; for (int i = 1; i <= n ; i++) { if(l%i == 0) arr[i-1] = l; else arr[i-1] = i-(l%i)+l; if(arr[i-1] > r){ out.println("NO"); return; } } out.println("YES"); for (int i = 0; i < n; i++) out.print(arr[i] +" "); out.println(); } //greatest common divisor public static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } public static void sort(int[] arr) { sort(arr, Comparator.naturalOrder()); } public static void sort(int[] arr, Comparator orderStyle) { //because Arrays.sort() uses quicksort which is dumb //Collections.sort() uses merge sort ArrayList<Integer> ls = new ArrayList<Integer>(); for(int x: arr) ls.add(x); Collections.sort(ls, orderStyle); for(int i=0; i < arr.length; i++) arr[i] = ls.get(i); } public static void sort(long[] arr) { sort(arr, Comparator.naturalOrder()); } public static void sort(long[] arr, Comparator orderStyle) { //because Arrays.sort() uses quicksort which is dumb //Collections.sort() uses merge sort ArrayList<Long> ls = new ArrayList<Long>(); for(long x: arr) ls.add(x); Collections.sort(ls, orderStyle); for(int i=0; i < arr.length; i++) arr[i] = ls.get(i); } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s){ br = new BufferedReader(new InputStreamReader(s));} public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException {return Integer.parseInt(next());} //public char nextChar() throws IOException {return next();} public long nextLong() throws IOException {return Long.parseLong(next());} public String nextLine() throws IOException {return br.readLine();} public double nextDouble() throws IOException { return Double.parseDouble(next()); } public boolean ready() throws IOException {return br.ready();} } }
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 8
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
50ac034a838e0ebecb21e8ac9f59bef3
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.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Ashutosh Patel (ashutoshpatelnoida@gmail.com) Linkedin : ( https://www.linkedin.com/in/ashutosh-patel-7954651ab/ ) */ 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(); int testCount = Integer.parseInt(in.next()); for (int i = 1; i <= testCount; i++) solver.solve(i, in, out); out.close(); } static class BDifferenceOfGCDs { public void solve(int testNumber, InputReader sc, OutputWriter out) { // int n = sc.readInt(), l = sc.readInt(), r = sc.readInt(); long n = sc.readLong(), l = sc.readLong(), r = sc.readLong(); ArrayList<Long> al = new ArrayList<>(); for (long i = 1; i <= n; i++) { long res = (long) ((Math.ceil((double) l / (double) i)) * i); if (res > r) { out.printLine("NO"); return; } al.add(res); } out.printLine("YES"); // out.printLine(al); for (long integer : al) { out.print(integer + " "); } out.printLine(); } } static class InputReader { private final InputStream stream; private final byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 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 long readLong() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long 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 readString() { int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { if (Character.isValidCodePoint(c)) { res.appendCodePoint(c); } c = read(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) { return filter.isSpaceChar(c); } return isWhitespace(c); } public String next() { return readString(); } public interface SpaceCharFilter { 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() { writer.println(); } public void printLine(Object... objects) { print(objects); writer.println(); } public void close() { writer.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 8
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
8f99ea8423a686d4f6b167be917f0e67
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.BigInteger; import java.util.*; public class Main { static long cr[][]=new long[1001][1001]; //static double EPS = 1e-7; static long mod=998244353; static long val=0;static int cnt=0; static boolean flag=true; static int res=Integer.MAX_VALUE; static int v=0; public static void main(String[] args) { FScanner sc = new FScanner(); //Arrays.fill(prime, true); //sieve(); //ncr(); StringBuilder sb = new StringBuilder(); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int arr[]=new int[n]; int l=sc.nextInt(); int r=sc.nextInt(); String ans="YES"; for(int i=1;i<=n;i++) { if(l%i==0) arr[i-1]=l; else { arr[i-1]=l+(i-l%i); if(arr[i-1]>r) { ans="NO"; break; } } } sb.append(ans); if(ans.equals("YES")) { sb.append("\n"); for(int i=0;i<n;i++) { sb.append(arr[i]+" "); } } sb.append("\n"); } System.out.println(sb.toString()); } public static String dfs(ArrayList<pair> arr,long ind,String s) { ind--; // System.out.println(ind+" #"); if(ind<s.length()) return ""+s.charAt((int) ind); int n=arr.size(); for(int i=n-1;i>=0;i--) { if(arr.get(i).c<=ind && arr.get(i).d>=ind) { return dfs(arr,arr.get(i).a+ (ind-arr.get(i).c) ,s); } } return ""; } public static boolean check(char c[][],int i,int j,int val) { int one=0,zero=0,cnt=0; if(i-1>=0) { cnt++; if(c[i-1][j]=='1') one++; else zero++; } if(j-1>=0) { cnt++; if(c[i][j-1]=='1') one++; else zero++; } if(i+1<c.length) { cnt++; if(c[i+1][j]=='1') one++; else if(c[i+1][j]=='0' ) zero++; } if(j+1<c[0].length) { cnt++; if(c[i][j+1]=='1') one++; else if(c[i][j+1]=='0' ) zero++; } cnt=cnt-zero-one; if(cnt>=2) return true; if(val==0 && (one==2 || (one+cnt>=2) ) ) return true; if(val==1 && (zero==2 || (zero+cnt>=2) ) ) return true; return false; } static int digits (long x, long y) { BigInteger bi = BigInteger.valueOf(x).multiply(BigInteger.valueOf(y)); return bi.toString().length(); } public 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; } public static long gcd(long a,long b) { return b==0 ? a:gcd(b,a%b); } /* public static void sieve() { prime[0]=prime[1]=false; int n=1000000; for(int p = 2; p*p <=n; p++) { if(prime[p] == true) { for(int i = p*p; i <= n; i += p) prime[i] = false; } } */ public static void ncr() { cr[0][0]=1; for(int i=1;i<=1000;i++) { cr[i][0]=1; for(int j=1;j<i;j++) { cr[i][j]=(cr[i-1][j-1]+cr[i-1][j])%mod; } cr[i][i]=1; } } } class pair { long a;long b;long c;long d; public pair(long a,long b,long c,long d) { this.a=a; this.b=b; this.c=c; this.d=d; } } class FScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer sb = new StringTokenizer(""); String next(){ while(!sb.hasMoreTokens()){ try{ sb = new StringTokenizer(br.readLine()); } catch(IOException e){ } } return sb.nextToken(); } String nextLine(){ try{ return br.readLine(); } catch(IOException e) { } return ""; } int nextInt(){ return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } int[] readArray(int n) { int a[] = new int[n]; for(int i=0;i<n;i++) a[i] = nextInt(); return a; } float nextFloat(){ return Float.parseFloat(next()); } double nextDouble(){ 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 8
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
361b4bd7e7c004dfaf8a5d574cc10c05
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.InputStreamReader; import java.io.PrintStream; import java.util.*; public class B { public static void main(String[] args) { MyScanner myScanner = new MyScanner(); PrintStream out = System.out; int t = myScanner.readInt(); while(t > 0) { int n,l,r; n = myScanner.readInt(); l = myScanner.readInt(); r = myScanner.readInt(); int[] ans = new int[n+1]; boolean flag = true; Set<Integer> used = new TreeSet<>(); for(int i=n;i>0;i--) { int canBeAssigned = getNum(l,r,i,used); if(canBeAssigned == -1) { flag = false; break; } ans[i] = canBeAssigned; used.add(canBeAssigned); } if(flag) { out.println("YES"); for(int i=1;i<=n;i++) { out.print(Integer.toString(ans[i])+" "); } out.println(""); } else out.println("NO"); t--; } } public static int getNum(int l,int r,int g,Set<Integer>used) { int ans = -1; int floor = (l/g)*g; while(floor <= r) { if(floor >= l && floor <= r) { ans = floor; break; } floor += g; } return ans; } public static class MyScanner { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer stringTokenizer = new StringTokenizer(""); public String next() { while(!stringTokenizer.hasMoreTokens()) { try { stringTokenizer = new StringTokenizer(bufferedReader.readLine()); } catch (Exception exception) { exception.printStackTrace(); } } return stringTokenizer.nextToken(); } public int readInt() { return Integer.parseInt(next()); } public long readLong() { return Long.parseLong(next()); } public double readDouble() {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 8
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
50159d8077a2a465c72a599fe1c2936c
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 b1749 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t,j,n,i,x,y; long l,r,a[]; boolean f; t=sc.nextInt(); for(j=1;j<=t;j++){ n=sc.nextInt(); l=sc.nextLong(); r=sc.nextLong(); a=new long[n]; f=true; for(i=1;i<=n;i++){ if(Math.floor(r/(double)i)<Math.ceil(l/(double)i)){ f=false; break; } a[i-1]=(long)Math.ceil(l/(double)i)*i; } if(f){ System.out.println("YES"); for(i=0;i<n;i++) System.out.print(a[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 8
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
a678b228f01d5261808c87bf19aa08bf
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.BigInteger; import java.util.*; import java.util.Map.Entry; public class Main { //static int [] arr; //static boolean prime[] = new boolean[1000]; //static int l; //static String s; static StringBuilder sb; //static HashSet<L> hs; //static HashSet<Long> hs = new HashSet<Long>(); // static int ans; // static boolean checked []; static final int mod = 1000000007; //static int[][] dp; static boolean visited[][]; //static int[] w ,v; //static int n; // static int arr[][]; //static long ans; static Scanner sc; static PrintWriter out; static int n,m,w,t; //static char [] a , b; static StringBuilder sb; static int ans; static int grid [] []; public static void main(String[] args) throws IOException, InterruptedException { sc = new Scanner(System.in); out = new PrintWriter(System.out); t =sc.nextInt(); while(t-->0) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); boolean ok = false; int [] arr = new int[n]; for(int i = 0 ; i < n ; i++) { ok = false; int ll = l/(i+1) -1; int rr = r/(i+1)+1; for(int j = ll ; j <= rr ; j++) { if(j*(i+1) >=l && j*(i+1)<=r) { ok = true; arr[i] = j*(i+1); break; } } if(!ok) break; } if(!ok) out.println("NO"); else { out.println("YES"); for(int x : arr) out.print(x+" "); out.println(); } } out.close(); } public static void solve() { //out.println(cost);, } // public static int trace(int idx,int cost){ // if(cost> t || idx == m) // return 0; // int take = v[idx] + solve(idx+1,cost + 3*w*d[idx]); // //int leave = solve(idx+1,t); // if(dp[idx][cost] == take){ // sb.append(d[idx]+" "+v[idx]+"\n"); // return 1 + trace(idx+1,cost+3*w*d[idx]); // } // // return trace(idx+1,cost); // } private static void reverse(long[] arr) { // TODO Auto-generated method stub } // recursive implementation static long arrayLCM(int[] arr, int idx) { // lcm(a,b) = (a*b/gcd(a,b)) if (idx == arr.length - 1){ return arr[idx]; } long a = arr[idx]; long b = arrayLCM(arr, idx+1); return (a*b/gcd(a,b)); // } static int longestSubarrWthSumDivByK(int arr[], int n, int k) { // unordered map 'um' implemented as // hash table HashMap<Integer, Integer> um= new HashMap<Integer, Integer>(); // 'mod_arr[i]' stores (sum[0..i] % k) int mod_arr[]= new int[n]; int max_len = 0; long curr_sum = 0; // traverse arr[] and build up the // array 'mod_arr[]' for (int i = 0; i < n; i++) { curr_sum += arr[i]; // as the sum can be negative, // taking modulo twice mod_arr[i] = (int)((curr_sum % k) + k) % k; // if true then sum(0..i) is // divisible by k if (mod_arr[i] == 0) // update 'max' max_len = i + 1; // if value 'mod_arr[i]' not present in 'um' // then store it in 'um' with index of its // first occurrence else if (um.containsKey(mod_arr[i]) == false) um.put(mod_arr[i] , i); else // if true, then update 'max' if (max_len < (i - um.get(mod_arr[i]))) max_len = i - um.get(mod_arr[i]); } // return the required length of longest subarray // with sum divisible by 'k' return max_len; } static int longestSubArrayOfSumK(int[] arr, int n, int k) { // HashMap to store (sum, index) tuples HashMap<Integer, Integer> map = new HashMap<>(); int sum = 0, maxLen = 0; // traverse the given array for (int i = 0; i < n; i++) { // accumulate sum sum += arr[i]; // when subarray starts from index '0' if (sum == k) maxLen = i + 1; // make an entry for 'sum' if it is // not present in 'map' if (!map.containsKey(sum)) { map.put(sum, i); } // check if 'sum-k' is present in 'map' // or not if (map.containsKey(sum - k)) { // update maxLength if (maxLen < (i - map.get(sum - k))) maxLen = i - map.get(sum - k); } } return maxLen; } static boolean isPrime(long n) { if (n == 2 || n == 3) return true; if (n <= 1 || n % 2 == 0 || n % 3 == 0) return false; // To check through all numbers of the form 6k ± 1 for (long i = 5; i * i <= n; i += 6) { if (n % i == 0 || n % (i + 2) == 0) return false; } return true; } static long smallestDivisor(long n){ // if divisible by 2 if (n % 2 == 0) return 2; // iterate from 3 to sqrt(n) for (long i = 3; i * i <= n; i += 2) { if (n % i == 0) return i; } return n; } static long nCr(int n, int r) { return fact(n) / (fact(r) * fact(n - r)); } static long fact(int n) { long res = 1; for (int i = 2; i <= n; i++) res = res * i; return res; } static long gcd(long a, long b) { if (a == 0) return b; return gcd(b % a, a); } public static boolean isSorted (int [] arr) { for(int i = 0 ; i < arr.length -1 ; i++) if(arr[i]>arr[i+1]) return false; return true; } // static void findsubsequences(String s, String ans){ // if (s.length() == 0) { // if(ans!="") // if(ans.length()!=l) // al.add(Long.parseLong(ans)); // return; // } // // // We add adding 1st character in string // findsubsequences(s.substring(1), ans + s.charAt(0)); // // // Not adding first character of the string // // because the concept of subsequence either // // character will present or not // findsubsequences(s.substring(1), ans); //} static void sieve(int n,boolean[] prime,List<Integer> al) { for(int i=0;i<=n;i++) prime[i] = true; for(int p = 2; p*p <=n; p++) { if(prime[p]) { al.add(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) // System.out.print(i + " "); // } public static void reverse(Object [] arr) { int i = 0; int j = arr.length-1; while(i<j) { Object temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; i++; j--; } } } class Pair implements Comparable <Pair>{ int a ; int b ; public Pair(int a , int b) { this.a = a; this.b = b; } @Override public int compareTo(Pair o) { // TODO Auto-generated method stub return this.a-o.a; } public String toString() { return "( " + this.a + " , " + this.b + " )\n"; } } class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public int[][] nextInt2DArr(int l, int w) throws IOException { int [][] arr = new int[l][w]; for(int i = 0 ; i < l ; i++) for(int j = 0 ; j<w ; j++) arr[i][j]= Integer.parseInt(next()); return arr; } public Scanner(String file) throws FileNotFoundException { br = new BufferedReader(new FileReader(file)); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public int[] nextIntArr(int length) throws IOException { int[] arr = new int[length]; for(int i = 0 ; i < length ; i++) arr[i] = Integer.parseInt(next()); return arr; } public long[] nextLongArr(int length) throws IOException { long[] arr = new long[length]; for(int i = 0 ; i < length ; i++) arr[i] = Long.parseLong(next()); return arr; } public boolean ready() throws IOException { return br.ready(); } }
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 8
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
d48a6463e76521b215a18f45589bc7ae
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 Solution { 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(); ArrayList<Integer> res = new ArrayList<>(); res.add(l); int c = 1; for(int i=2; i<=n; i++){ if(l%i == 0){ res.add(l); c++; }else{ int j = (l/i + 1)*i; if(j <= r){ res.add(j); c++; }else{ break; } } } if(c == n){ System.out.println("YES"); for(int e: res) System.out.print(e + " "); 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 8
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
9524c2f9a3f5e92b3762cb9b3ff55bfc
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.StringTokenizer; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Queue; import java.util.ArrayList; import java.util.List; import java.util.Collections; import java.util.Queue; import java.util.LinkedList; import java.util.Arrays; public class Main{ private static FastReader fs; public static void main(String[] args) throws Exception{ fs = new FastReader(); int test =fs.nextInt(); // int test = 1; while(test-- > 0) solve(); } 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; } } // use fs as scanner // snippets -> sieve, power, Node , lowerbound, upperbound, readarray public static void solve(){ int n = fs.nextInt(); int l = fs.nextInt(); int r = fs.nextInt(); List<Integer> _res = new ArrayList<>(); _res.add(l); int cnt = 1; for(int i=2; i<=n; i++){ if( (l % i) == 0 ){ _res.add(l); cnt++; } else{ int close = l / i; close = (close+1) * i; if( close <= r ){ _res.add(close); cnt++; } else{ break; } } } if( cnt == n ){ System.out.println("YES"); StringBuilder str = new StringBuilder(); for(int ele : _res) str.append(ele + " "); System.out.println(str); } else{ System.out.println("NO"); } } } /* do something when you are stuck and be calm */
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 8
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
5a9bc5f2e49c64fa1ee12f9ba296bb86
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.StringTokenizer; public class gcdDiff { public static void main(String[] args) throws IOException { BufferedReader bi = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(bi.readLine()); int t = Integer.parseInt(st.nextToken()); for(int i = 0; i < t; i++) { st = new StringTokenizer(bi.readLine()); int n = Integer.parseInt(st.nextToken()); int l = Integer.parseInt(st.nextToken()); int r = Integer.parseInt(st.nextToken()); int[] array = new int[n]; int j = 1; for(; j <= n; j++) { int x = ((l-1)/j +1)*j; if(x <= r) { array[j-1] = x; } else { out.println("NO"); break; } } if(j == n+1) { out.println("YES"); for(int k = 0; k < n; k++) { out.print(array[k] + " "); } 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 8
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
ef8b0d2c25086f1bec3b352ec43595e3
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(); // if(n<=(r-l+1)){ // System.out.println("YES"); int[]arr=new int[n+1]; int cnt=0; for(int i=1;i<=n;i++){ if(l%i==0) arr[i]=l; else if(l+(i-l%i) >=l && l+(i-l%i) <=r ) arr[i]=l+(i-l%i); else break; cnt++; } if(cnt==n){ System.out.println("YES"); for(int i=1;i<=n;i++){ System.out.println(arr[i]+" "); } System.out.println(""); } else{ System.out.println("NO"); } } } // int[]arr=new int[n]; // for(int i=0;i<n;i++){ // arr[i]=sc.nextInt(); // } // Arrays.sort(arr); // int cnt=0; // // System.out.println(m); // m=m-arr[n-1]-(k-1); // n--; // while(m>0){ // if(n==0){ // cnt=-1; // break; // } // m=m-arr[n-1]+1; // n--; // cnt++; // } // System.out.println(cnt); }
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 8
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
438dda6ea2132bb11209c170ad8af218
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
//---#ON_MY_WAY--- //---#THE_SILENT_ONE--- import static java.lang.Math.*; import java.io.*; import java.math.*; import java.util.*; public class apples { static FastReader x = new FastReader(); static OutputStream outputStream = System.out; static PrintWriter out = new PrintWriter(outputStream); /*---------------------------------------CODE STARTS HERE-------------------------*/ public static void main(String[] args) throws NumberFormatException, IOException { long startTime = System.nanoTime(); int mod = 1000000007; int t = x.nextInt(); StringBuilder str = new StringBuilder(); while (t > 0) { int n = x.nextInt(), l = x.nextInt(), r = x.nextInt(); boolean f = true; long a[] = new long[n]; for(int i = 1; i <= n; i++) { long k = (((l-1)/i)+1)*i; a[i-1] = k; if(k>r) { f = false; break; } } if(f) { str.append("YES\n"); for(long i : a) str.append(i+" "); } else str.append("NO"); str.append("\n"); t--; } out.println(str); out.flush(); long endTime = System.nanoTime(); //System.out.println((endTime-startTime)/1000000000.0); } /*--------------------------------------------FAST I/O-------------------------------*/ 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; } char nextchar() { char ch = ' '; try { ch = (char) br.read(); } catch (IOException e) { e.printStackTrace(); } return ch; } } /*--------------------------------------------HELPER---------------------------------*/ static class pair implements Comparable<pair> { int x, y; public pair(int a, int b) { x = a; y = b; } @Override public int hashCode() { int hash = 3; hash = 47 * hash + this.x; hash = 47 * hash + this.y; return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final pair other = (pair) obj; if (this.x != other.x) { return false; } if (this.y != other.y) { return false; } return true; } @Override public int compareTo(apples.pair o) { if(this.x==o.x) return this.y-o.y; return this.x-o.x; } } /*--------------------------------------------BOILER PLATE---------------------------*/ static int[] readarr(int n) { int arr[] = new int[n]; for (int i = 0; i < n; i++) { arr[i] = x.nextInt(); } return arr; } static int[] sortint(int a[]) { ArrayList<Integer> al = new ArrayList<>(); for (int i : a) { al.add(i); } Collections.sort(al); for (int i = 0; i < a.length; i++) { a[i] = al.get(i); } return a; } static long[] sortlong(long a[]) { ArrayList<Long> al = new ArrayList<>(); for (long i : a) { al.add(i); } Collections.sort(al); for (int i = 0; i < al.size(); i++) { a[i] = al.get(i); } return a; } static long pow(long x, long y) { long result = 1; while (y > 0) { if (y % 2 == 0) { x = x * x; y = y / 2; } else { result = result * x; y = y - 1; } } return result; } static long pow(long x, long y, long mod) { long result = 1; x %= mod; while (y > 0) { if (y % 2 == 0) { x = (x % mod * x % mod) % mod; y /= 2; } else { result = (result % mod * x % mod) % mod; y--; } } return result; } static int[] revsort(int a[]) { ArrayList<Integer> al = new ArrayList<>(); for (int i : a) { al.add(i); } Collections.sort(al, Comparator.reverseOrder()); for (int i = 0; i < a.length; i++) { a[i] = al.get(i); } return a; } static int[] gcd(int a, int b, int ar[]) { if (b == 0) { ar[0] = a; ar[1] = 1; ar[2] = 0; return ar; } ar = gcd(b, a % b, ar); int t = ar[1]; ar[1] = ar[2]; ar[2] = t - (a / b) * ar[2]; return ar; } static boolean[] esieve(int n) { boolean p[] = new boolean[n + 1]; Arrays.fill(p, true); for (int i = 2; i * i <= n; i++) { if (p[i] == true) { for (int j = i * i; j <= n; j += i) { p[j] = false; } } } return p; } static ArrayList<Integer> primes(int n) { boolean p[] = new boolean[n + 1]; ArrayList<Integer> al = new ArrayList<>(); Arrays.fill(p, true); int i = 0; for (i = 2; i * i <= n; i++) { if (p[i] == true) { al.add(i); for (int j = i * i; j <= n; j += i) { p[j] = false; } } } for (i = i; i <= n; i++) { if (p[i] == true) { al.add(i); } } return al; } static int etf(int n) { int res = n; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { res /= i; res *= (i - 1); while (n % i == 0) { n /= i; } } } if (n > 1) { res /= n; res *= (n - 1); } return res; } static int gcd(int a, int b) { if (a == 0) { return b; } return gcd(b % a, a); } static long gcd(long a, long b) { if (a == 0) { return b; } 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 8
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
36c944eba3f1afc6c63454a178faae7e
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 { // Alphabet size (# of symbols) public static class Pair implements Comparable < Pair > { int d; int i; Pair(int i, int d) { this.d = d; this.i = i; } public int compareTo(Pair o) { if (this.d == o.d) return this.i - o.i; if (this.d < o.d) return -1; else return 1; } } public static class SegmentTree { long[] st; long[] lazy; int n; SegmentTree(long[] arr, int n) { this.n = n; st = new long[4 * n]; lazy = new long[4 * n]; construct(arr, 0, n - 1, 0); } public long construct(long[] arr, int si, int ei, int node) { if (si == ei) { st[node] = arr[si]; return arr[si]; } int mid = (si + ei) / 2; long left = construct(arr, si, mid, 2 * node + 1); long right = construct(arr, mid + 1, ei, 2 * node + 2); st[node] = left + right; return st[node]; } public long get(int l, int r) { return get(0, n - 1, l, r, 0); } public long get(int si, int ei, int l, int r, int node) { if (r < si || l > ei) return 0; if (lazy[node] != 0) { st[node] += lazy[node] * (ei - si + 1); if (si != ei) { lazy[2 * node + 1] += lazy[node]; lazy[2 * node + 2] += lazy[node]; } lazy[node] = 0; } if (l <= si && r >= ei) return st[node]; int mid = (si + ei) / 2; return get(si, mid, l, r, 2 * node + 1) + get(mid + 1, ei, l, r, 2 * node + 2); } public void update(int index, int value) { update(0, n - 1, index, 0, value); } public void update(int si, int ei, int index, int node, int val) { if (si == ei) { st[node] = val; return; } int mid = (si + ei) / 2; if (index <= mid) { update(si, mid, index, 2 * node + 1, val); } else { update(mid + 1, ei, index, 2 * node + 2, val); } st[node] = st[2 * node + 1] + st[2 * node + 2]; } public void rangeUpdate(int l, int r, int val) { rangeUpdate(0, n - 1, l, r, 0, val); } public void rangeUpdate(int si, int ei, int l, int r, int node, int val) { if (r < si || l > ei) return; if (lazy[node] != 0) { st[node] += lazy[node] * (ei - si + 1); if (si != ei) { lazy[2 * node + 1] += lazy[node]; lazy[2 * node + 2] += lazy[node]; } lazy[node] = 0; } if (l <= si && r >= ei) { st[node] += val * (ei - si + 1); if (si != ei) { lazy[2 * node + 1] += val; lazy[2 * node + 2] += val; } return; } int mid = (si + ei) / 2; rangeUpdate(si, mid, l, r, 2 * node + 1, val); rangeUpdate(mid + 1, ei, l, r, 2 * node + 2, val); st[node] = st[2 * node + 1] + st[2 * node + 2]; } } 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') { if (cnt != 0) { break; } else { continue; } } 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(); } } public static void main(String[] args) throws IOException { if (System.getProperty("ONLINE_JUDGE") == null) { try { System.setIn(new FileInputStream(new File("input.txt"))); System.setOut(new PrintStream(new File("output.txt"))); } catch (Exception e) { } } Reader sc = new Reader(); int tc = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (tc-- > 0) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); ArrayList<Integer> ans = new ArrayList<>(); for (int i = 1; i <= n; i++) { int k = (int)Math.ceil(l * 1.0 / i); if ((k * i) >= l && (k * i) <= r) ans.add(k * i); } if (ans.size() == n) { sb.append("YES" + "\n"); for (int i = 1; i <= n; i++) sb.append(ans.get(i - 1) + " "); } else { sb.append("NO"); } sb.append("\n"); } System.out.println(sb); } public static int log2(long N) { // calculate log2 N indirectly // using log() method int result = (int)Math.ceil((Math.log(N) / Math.log(2))); return result; } static long power(long x, long y, long p) { long res = 1; // Initialize result // Update x if it is more // than or equal to p x = x % p; while (y > 0) { // If y is odd, multiply // x with the 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; } public static int countBit(int n) { int count = 0; while (n > 0) { count += 1; n /= 2; } return count; } public static int get(int[] dsu, int x) { if (dsu[x] == x) return x; int k = get(dsu, dsu[x]); dsu[x] = k; return k; } static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } public static int Xor(int n) { 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; } public static long pow(long a, long b, long mod) { long res = 1; while (b > 0) { if ((b & 1) > 0) res = (res * a) % mod; b = b >> 1; a = ((a % mod) * (a % mod)) % mod; } return (res % mod + mod) % mod; } public static double digit(long num) { return Math.floor(Math.log10(num) + 1); } static int upperBound(ArrayList<Long> arr, long key) { int mid, N = arr.size(); // 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.get(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 return low; } static int lowerBound(ArrayList<Long> array, long key) { // Initialize starting index and // ending index int low = 0, high = array.size(); 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.get(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 < array.size() && array.get(low) < key) { low++; } // Returning the lower_bound index return low; } }
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 8
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
a79538bca844aae0856ccde972006d11
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
/* I am dead inside Do you like NCT, sKz, BTS? 5 4 3 2 1 Moonwalk Imma knock it down like domino Is this what you want? Is this what you want? Let's ttalkbocky about that :() */ import static java.lang.Math.*; import java.util.*; import java.io.*; public class x1708B { static final int INF = Integer.MAX_VALUE/2; public static void main(String[] followthekkathyoninsta) throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(infile.readLine()); int T = Integer.parseInt(st.nextToken()); StringBuilder sb = new StringBuilder(); tc:while(T-->0) { int[] input = readArr(3, infile, st); int N = input[0]; int L = input[1]; int R = input[2]; int[] res = new int[N]; for(int i=1; i <= N; i++) { //find multiple long low = 1L; long high = 1000000000L; while(low != high) { long mid = (low+high)>>1; if(mid*i >= L) high = mid; else low = mid+1; } if(low*i > R) { sb.append("NO\n"); continue tc; } res[i-1] = (int)(low*i); } sb.append("YES\n"); for(int x: res) sb.append(x+" "); sb.append("\n"); } System.out.print(sb); } public static int[] readArr(int N, BufferedReader infile, StringTokenizer st) throws Exception { int[] arr = new int[N]; st = new StringTokenizer(infile.readLine()); for(int i=0; i < N; i++) arr[i] = Integer.parseInt(st.nextToken()); return arr; } } /* gcd(1, a1) = 1 gcd(2, a2) = 2 gcd(3, a3) = 3 ... gcd(n, an) = n */
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 8
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
eced99d940e0009199ac8b1c2dc14782
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 MyCpClass{ public static void main(String []args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int T = Integer.parseInt(br.readLine().trim()); while(T-- > 0){ String []str = br.readLine().trim().split(" "); int n = Integer.parseInt(str[0]); int l = Integer.parseInt(str[1]); int r = Integer.parseInt(str[2]); String ans = "YES"; int []a = new int[n]; for(int i=0; i<n; i++){ int ind = i+1; if(l%ind == 0) a[i] = l; else{ int l1 = l + ind - l%ind; if(l1 <= r) a[i] = l1; else{ ans = "NO"; break; } } } sb.append(ans + "\n"); if(ans.equals("YES")){ for(int x : a) sb.append(x + " "); sb.append("\n"); } } 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 8
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
5b91b3b81e89d1a19f7731c534cd4d59
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{ static FastReader sc=null; public static void main(String[] args) { sc=new FastReader(); int t=sc.nextInt(); PrintWriter out=new PrintWriter(System.out); for(int tt=0;tt<t;tt++) { int n=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt(); int ans[]=new int[n]; boolean bad=false; for(int i=n;i>=1;i--) { int d=r%i; int val=r-d; if(val<l) { bad=true; break; } ans[i-1]=val; } if(bad) { out.println("NO"); } else { out.println("YES"); for(int e:ans)out.print(e+" "); out.println(); } } out.close(); } static int[] ruffleSort(int a[]) { ArrayList<Integer> al=new ArrayList<>(); for(int i:a)al.add(i); Collections.sort(al); for(int i=0;i<a.length;i++)a[i]=al.get(i); return a; } static void print(int a[]) { for(int e:a) { System.out.print(e+" "); } System.out.println(); } static class FastReader{ StringTokenizer st=new StringTokenizer(""); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 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()); } long nextLong() { return Long.parseLong(next()); } int[] readArray(int n) { int a[]=new int[n]; for(int i=0;i<n;i++)a[i]=sc.nextInt(); 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 8
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
fee315f08ebbafa4fb413a890648f232
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
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.*; /** * * @author Ather Ali Siddiqui */ public class NewClass { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-- >0){ StringBuilder ans = new StringBuilder(); int n = in.nextInt() , l = in.nextInt() ,left = l, r = in.nextInt(),right = r , i = 1 ,num =0; for( ; i <= n ; i++){ num = ( (left - 1 ) / i + 1 ) * i; if( num > right)break; ans.append(num).append(" "); } // System.out.println("test = "+ans.toString()); if( i == n + 1) System.out.println("YES\n"+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 8
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
eee30c00a60d0740ecf233b035db5a43
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 int gcd(int a, int b) { // if(b==0) return a; // return gcd(a, b%a); // } public static void main (String[] args) throws java.lang.Exception { try { Scanner sc=new Scanner(System.in); // int t=sc.nextInt(); // while(t-- > 0) { // } int t=sc.nextInt(); while(t-- > 0) { int n=sc.nextInt(); int l=sc.nextInt(); int r=sc.nextInt(); int[] arr=new int[n+1]; boolean ok=true; for(int i=1; i<=n; i++) { arr[i]=(((l-1)/i)+1)*i; if(ok&&arr[i] > r) {ok=false; break;} } if(ok) {System.out.println("YES"); for(int i=1; i<=n; i++) System.out.print(arr[i]+" "); System.out.println(); } else System.out.println("NO"); // boolean ok=true; // if(set.size()==1) System.out.println("YES"); // else if(n==2 && arr[2]%arr[1]==0) System.out.println("YES"); // else { // for(int i=2; i<=n; i++) { // if(arr[i]-arr[i-1]!=1){ // ok=false; break; // } // } // if(!ok) System.out.println("NO"); // else System.out.println("YES"); // } } } catch(Exception e) { } // 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 8
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
7b67ef33cd09810a77a8dbbaf3199b13
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 B1708 { public static void main(String ar[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int tt=0;tt<t;tt++) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int a[] = new int[n]; boolean flag = false; for(int i=1;i<=n;i++) { int rem = l%i; if(rem==0) { a[i-1] = l; } else if(l+i-rem<=r) { a[i-1] = l+i-rem; } else { flag = true; break; } } if(n==1) { System.out.println("YES"); System.out.println(l); } else { if(!flag) { System.out.println("YES"); for(int i=0;i<n;i++) { System.out.print(a[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 8
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
680aeecb07f8d21caf6e7272c9b0c066
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_Difference_of_GCDs { static Scanner in = new Scanner(); static PrintWriter out = new PrintWriter(System.out); static StringBuilder ans = new StringBuilder(); static int testCases, n; static long l, r; static long a[]; static void solve(int t) { long finalAns[] = new long[n]; StringBuilder sb = new StringBuilder(); ArrayList1<Long> list = new ArrayList1<>(); for (int i = 1; i <= n; ++i) { if (l % (i) == 0) { list.add((long) l); } else { long x = (l+(i))-(l%(i)); if (x > r) { break; } else { list.add(x); } } } if (list.size() == n) { int index = 0; while (!list.isEmpty()) { finalAns[index++] = list.get(0); list.popFront(); } for (int i = 0; i < n; ++i) { if (finalAns[i] < l || finalAns[i] > r) { ans.append("NO"); if (t != testCases) { ans.append("\n"); } return; } } ans.append("YES").append("\n"); for (long i : finalAns) { sb.append(i).append(" "); } ans.append(sb.toString().trim()); } else { ans.append("NO"); } if (t != testCases) { ans.append("\n"); } } public static void main(String[] priya) throws IOException { testCases = in.nextInt(); for (int t = 0; t < testCases; ++t) { n = in.nextInt(); l = in.nextLong(); r = in.nextLong(); solve(t + 1); } in.close(); out.print(ans.toString()); out.flush(); } static long gcd(long n1, long n2) { if (n2 != 0) { return gcd(n2, n1 % n2); } else { return n1; } } static int search(long a[], long x, int last) { int i = 0, j = last; while (i <= j) { int mid = i + (j - i) / 2; if (a[mid] == x) { return mid; } if (a[mid] < x) { i = mid + 1; } else { j = mid - 1; } } return -1; } static void swap(long a[], int i, int j) { long temp = a[i]; a[i] = a[j]; a[j] = temp; } static void reverse(long a[]) { n = a.length; for (int i = 0; i < n / 2; ++i) { swap(a, i, n - i - 1); } } static long max(long a[], int i, int n, long max) { if (i > n) { return max; } max = Math.max(a[i], max); return max(a, i + 1, n, max); } static long min(long a[], int i, int n, long max) { if (i > n) { return max; } max = Math.min(a[i], max); return max(a, i + 1, n, max); } static void printArray(long a[]) { for (long i : a) { System.out.print(i + " "); } System.out.println(); } static boolean isSmaller(String str1, String str2) { 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; } static String sub(String str1, String str2) { if (isSmaller(str1, str2)) { String t = str1; str1 = str2; str2 = t; } String str = ""; int n1 = str1.length(), n2 = str2.length(); int diff = n1 - n2; int carry = 0; for (int i = n2 - 1; i >= 0; i--) { int sub = (((int) str1.charAt(i + diff) - (int) '0') - ((int) str2.charAt(i) - (int) '0') - carry); if (sub < 0) { sub = sub + 10; carry = 1; } else { carry = 0; } str += String.valueOf(sub); } for (int i = n1 - n2 - 1; i >= 0; i--) { if (str1.charAt(i) == '0' && carry > 0) { str += "9"; continue; } int sub = (((int) str1.charAt(i) - (int) '0') - carry); if (i > 0 || sub > 0) { str += String.valueOf(sub); } carry = 0; } return new StringBuilder(str).reverse().toString(); } static String sum(String str1, String str2) { if (str1.length() > str2.length()) { String t = str1; str1 = str2; str2 = t; } String str = ""; int n1 = str1.length(), n2 = str2.length(); int diff = n2 - n1; int carry = 0; for (int i = n1 - 1; i >= 0; i--) { int sum = ((int) (str1.charAt(i) - '0') + (int) (str2.charAt(i + diff) - '0') + carry); str += (char) (sum % 10 + '0'); carry = sum / 10; } for (int i = n2 - n1 - 1; i >= 0; i--) { int sum = ((int) (str2.charAt(i) - '0') + carry); str += (char) (sum % 10 + '0'); carry = sum / 10; } if (carry > 0) { str += (char) (carry + '0'); } return new StringBuilder(str).reverse().toString(); } static long detect_sum(int i, long a[], long sum) { if (i >= a.length) { return sum; } return detect_sum(i + 1, a, sum + a[i]); } static String mul(String num1, String num2) { int len1 = num1.length(); int len2 = num2.length(); if (len1 == 0 || len2 == 0) { return "0"; } int result[] = new int[len1 + len2]; int i_n1 = 0; int i_n2 = 0; for (int i = len1 - 1; i >= 0; i--) { int carry = 0; int n1 = num1.charAt(i) - '0'; i_n2 = 0; for (int j = len2 - 1; j >= 0; j--) { int n2 = num2.charAt(j) - '0'; int sum = n1 * n2 + result[i_n1 + i_n2] + carry; carry = sum / 10; result[i_n1 + i_n2] = sum % 10; i_n2++; } if (carry > 0) { result[i_n1 + i_n2] += carry; } i_n1++; } int i = result.length - 1; while (i >= 0 && result[i] == 0) { i--; } if (i == -1) { return "0"; } String s = ""; while (i >= 0) { s += (result[i--]); } return s; } static class Node<T> { T data; Node<T> next; public Node() { this.next = null; } public Node(T data) { this.data = data; this.next = null; } public T getData() { return data; } public void setData(T data) { this.data = data; } public Node<T> getNext() { return next; } public void setNext(Node<T> next) { this.next = next; } @Override public String toString() { return this.getData().toString() + " "; } } static class ArrayList1<T> { Node<T> head, tail; int len; public ArrayList1() { this.head = null; this.tail = null; this.len = 0; } int size() { return len; } boolean isEmpty() { return len == 0; } int indexOf(T data) { if (isEmpty()) { throw new ArrayIndexOutOfBoundsException(); } Node<T> temp = head; int index = -1, i = 0; while (temp != null) { if (temp.getData() == data) { index = i; } i++; temp = temp.getNext(); } return index; } void add(T data) { Node<T> newNode = new Node<>(data); if (isEmpty()) { head = newNode; tail = newNode; len++; } else { tail.setNext(newNode); tail = newNode; len++; } } void see() { if (isEmpty()) { throw new ArrayIndexOutOfBoundsException(); } Node<T> temp = head; while (temp != null) { out.print(temp.getData().toString() + " "); out.flush(); temp = temp.getNext(); } out.println(); out.flush(); } void inserFirst(T data) { Node<T> newNode = new Node<>(data); Node<T> temp = head; if (isEmpty()) { head = newNode; tail = newNode; len++; } else { newNode.setNext(temp); head = newNode; len++; } } T get(int index) { if (isEmpty() || index >= len) { throw new ArrayIndexOutOfBoundsException(); } if (index == 0) { return head.getData(); } Node<T> temp = head; int i = 0; T data = null; while (temp != null) { if (i == index) { data = temp.getData(); } i++; temp = temp.getNext(); } return data; } void addAt(T data, int index) { if (index >= len) { throw new ArrayIndexOutOfBoundsException(); } Node<T> newNode = new Node<>(data); int i = 0; Node<T> temp = head; while (temp.next != null) { if (i == index) { newNode.setNext(temp.next); temp.next = newNode; } i++; temp = temp.getNext(); } // temp.setNext(temp); len++; } void popFront() { if (isEmpty()) { //return; throw new ArrayIndexOutOfBoundsException(); } if (head == tail) { head = null; tail = null; } else { head = head.getNext(); } len--; } void removeAt(int index) { if (index >= len) { throw new ArrayIndexOutOfBoundsException(); } if (index == 0) { this.popFront(); return; } Node<T> temp = head; int i = 0; Node<T> n = new Node<>(); while (temp != null) { if (i == index) { n.next = temp.next; temp.next = n; break; } i++; n = temp; temp = temp.getNext(); } tail = n; --len; } void clearAll() { this.head = null; this.tail = null; } } static void merge(long a[], int left, int right, int mid) { int n1 = mid - left + 1, n2 = right - mid; long L[] = new long[n1]; long R[] = new long[n2]; for (int i = 0; i < n1; i++) { L[i] = a[left + i]; } for (int i = 0; i < n2; i++) { R[i] = a[mid + 1 + i]; } int i = 0, j = 0, k1 = left; while (i < n1 && j < n2) { if (L[i] <= R[j]) { a[k1] = L[i]; i++; } else { a[k1] = R[j]; j++; } k1++; } while (i < n1) { a[k1] = L[i]; i++; k1++; } while (j < n2) { a[k1] = R[j]; j++; k1++; } } static void sort(long a[], int left, int right) { if (left >= right) { return; } int mid = (left + right) / 2; sort(a, left, mid); sort(a, mid + 1, right); merge(a, left, right, mid); } static class Scanner { BufferedReader in; StringTokenizer st; public Scanner() { in = new BufferedReader(new InputStreamReader(System.in)); } String next() throws IOException { while (st == null || !st.hasMoreElements()) { st = new StringTokenizer(in.readLine()); } return st.nextToken(); } String nextLine() throws IOException { return in.readLine(); } int nextInt() throws IOException { return Integer.parseInt(next()); } double nextDouble() throws IOException { return Double.parseDouble(next()); } long nextLong() throws IOException { return Long.parseLong(next()); } void close() throws IOException { in.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 8
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
939463415b19a1b83950018dc9c481fc
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 Solution{ public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0){ solver(s); } } public static void solver(Scanner s){ int n = s.nextInt(); int l = s.nextInt(); int r = s.nextInt(); ArrayList<Integer> arr = new ArrayList<>(); arr.add(l); for(int i = 2;i<=n;i++){ int rem = l%i; if(rem==0) arr.add(l); else{ rem=i-rem; if(l+rem<=r) arr.add(l+rem); else{ System.out.println("NO"); return; } } } System.out.println("YES"); for(int i = 0;i<arr.size()-1;i++){ System.out.print(arr.get(i)+" "); } System.out.println(arr.get(arr.size()-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 8
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
4fa9ca67a9d0e4b64d3f0ffdab00d51e
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{ public static void main (String[] args) { int t=sc.nextInt(); while(t--!=0) {int n=sc.nextInt(); long l=sc.nextLong(); long r=sc.nextLong(); long arr1[]=new long[n];int p=0;long a=0; for(int i=0;i<n;i++) { a=l%(i+1); if(a==0) { arr1[p++]=l; } else { arr1[p++]=(l+(i+1)-(l%(i+1))); } } long max=0; for(int i=0;i<n;i++) { max=Math.max(max,arr1[i]); } if(max>r) { out.println("NO"); } else { out.println("YES"); for(int i=0;i<n;i++) { out.print(arr1[i]+" "); } out.println(""); } } //////////////////////////////////////////////////////////////////// out.flush();out.close(); }//*END OF MAIN METHOD* static final Random random = new Random(); static class FastScanner { public long[][] readArrayL; 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()); } long[] ArrayL(int n) { long a[]=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } int[] ArrayI(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()); } } static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); static FastScanner sc = new FastScanner(); }//*END OF MAIN CLASS* //hard work wins over skill /**** General tips 1. It is ok to fail, but it is not ok to fail for the same mistakes over and over! 2. Train smarter, not harder! 3. If you find an answer and want to return immediately, don't forget to flush before return! Read before practice 1. Set a timer based on a problem's difficulty level: 45 minutes at your current target practice level; 2. During a problem solving session, focus! Do not switch problems or even worse switch to do something else; 3. If fail to solve within timer limit, read editorials to get as little help as possible to get yourself unblocked; 4. If after reading the entire editorial and other people's code but still can not solve, move this problem to to-do list and re-try in the future. 5. Keep a practice log about new thinking approaches, good tricks, bugs; Review regularly; 6. Also try this new approach suggested by um_nik: Solve with no intention to read editorial. If getting stuck, skip it and solve other similar level problems. Wait for 1 week then try to solve again. Only read editorial after you solved a problem. 7. Remember to also submit in the original problem link (if using gym) so that the 1 v 1 bot knows which problems I have solved already. 8. Form the habit of writing down an implementable solution idea before coding! You've taken enough hits during contests because you rushed to coding! Read before contests and lockout 1 v 1 Mistakes you've made in the past contests: 1. Tried to solve without going through given test examples -> wasting time on solving a different problem than asked; 2. Rushed to coding without getting a comprehensive sketch of your solution -> implementation bugs and WA; Write down your idea step by step, no need to rush. It is always better to have all the steps considered before hand! Think about all the past contests that you have failed because slow implementation and implementation bugs! This will be greatly reduced if you take your time to get a thorough idea steps! 3. Forgot about possible integer overflow; When stuck: 1. Understand problem statements? Walked through test examples? 2. Take a step back and think about other approaches? 3. Check rank board to see if you can skip to work on a possibly easier problem? 4. If none of the above works, take a guess? **/
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 8
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
9d1aa0aca8de4673c64eaaf45349616e
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 DifferenceGcd { public static void solve(Scanner sc) { int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[] arr = new int[n+1]; int k = 1; int count = 0; int l1 = l; int r1 = r; for(int j = 1; j <= n; j++) { int q = r / j; int n1 = q*j; if(n1 < l) { System.out.println("NO"); return; } arr[j] = n1; } System.out.println("YES"); for(int i = 1; i <= n; i++) { System.out.print(arr[i] + " "); } System.out.println(); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = Integer.parseInt(sc.nextLine()); while(t-->0) { solve(sc); } } }
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 8
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
157567209d342f96dd17b6e439b107f2
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 Dev { static void solve(){ ArrayList<Integer> ans = new ArrayList<>(); for(int i=0; i<1000; i++){ ans.add(i*2); } } public static void main(String[] args){ try{ System.setIn(new FileInputStream("input.txt")); System.setOut(new PrintStream(new FileOutputStream("output.txt"))); } catch(Exception e){ System.err.println("Error"); } Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int p=0; p<t; p++){ int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); ArrayList<Integer> ans = new ArrayList<>(); int is=1; solve(); for(int i=0; i<n; i++){ int x = l/(i+1); int y = x; while(true){ if((i+1)*y<l){ y++; }else{ break; } } if((i+1)*y>r){ is=0; break; } ans.add((i+1)*y); } if(is==1){ System.out.println("YES"); for(int i=0; i<n; i++){ System.out.print(ans.get(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 8
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
7df8ccd579e31269e8a5b00242883c31
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 void main(String[] args) throws Exception { try { FastReader sc = new FastReader(); int t = sc.nextInt(); while (t-- > 0) { int n =sc.nextInt(); int l =sc.nextInt(); int r =sc.nextInt(); int ans = l; ArrayList<Integer> list = new ArrayList<>(); for(int i=0;i<n;i++){ int a = l%(i+1); if(a==0){ list.add(l); }else{ list.add(l+(i+1)-(l%(i+1))); } } int max=list.get(0); for(int i:list) max = Math.max(max, i); if(max>r){ System.out.println("NO"); }else{ System.out.println("YES"); for(int i:list) System.out.print(i+" "); System.out.println(); } } } catch (Exception e) { } } public static int gcd(int m, int n) { if (n == 0) return m; return gcd(n, m % n); } }
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 8
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
6ec56d897acd5911de357a409b69a207
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 Pair{ static int mod=1000000007; static int n; static long arr[]; static long b[]; public static void main(String[] args){ FastScanner s = new FastScanner(); int t=s.nextInt(); while(t-->0) { n=s.nextInt(); int l=s.nextInt(); int r=s.nextInt(); StringBuilder sb= new StringBuilder(); sb.append(l+" "); boolean pos=true; for(int i=2;i<=n;i++) { int rem=0; if(i>l) { if(r>=i) { sb.append(i+" "); continue; }else { pos=false; break; } }else { rem=l%i; } if(rem==0) { sb.append(l+" "); continue; } if((l+(i-rem))<=r) { sb.append((l+(i-rem))+" "); }else { pos=false; break; } } if(pos) { System.out.println("YES"); System.out.println(sb); }else { System.out.println("NO"); } } } // Amd 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 8
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
11dea70bc0dc8e0299127f34bdd74304
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 { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine());// n is no of test cases for (int i = 0; i < n; i++) { String str=br.readLine(); ArrayList<Long> ans=new ArrayList<>(); for(String s:str.split(" ")){ ans.add(Long.parseLong(s)); } fnc(ans); } } // we want the multiple of i to be present !! public static void fnc(ArrayList<Long> a1){ long n=a1.get(0); long l=a1.get(1); long r=a1.get(2); // we need to handle the case seperately where we have the l < n // then take the % with r ig !! ArrayList<Long> arr=new ArrayList<>(); HashSet<Long> hs=new HashSet<>(); if(l<n){ for(int i=1;i<=n;i++){ long temp=r%i; long x=r-temp; if(x<l){ System.out.println("NO"); return; } arr.add(x); } System.out.println("YES"); for(long val:arr){ System.out.print(val+" "); } System.out.println(); return; } for(int i=1;i<=n;i++){ long temp=l%i; long x=0; if(temp!=0){ x=l+(i-temp); } else{ x=l; } if(x>r){ System.out.println("NO"); return; } arr.add(x); } System.out.println("YES"); for(long val:arr){ System.out.print(val+" "); } 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 8
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
875a357f218f861a473f1f837840d02b
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.PrintWriter; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.FileReader; import java.io.IOException; import java.util.StringTokenizer; import java.util.ArrayList; import java.util.Collections; import java.util.Arrays; import java.util.Stack; import java.util.HashSet; import java.util.HashMap; import java.util.TreeSet; import java.util.TreeMap; import java.util.Map; import java.util.PriorityQueue; import java.util.ArrayDeque; import static java.lang.Math.min; import static java.lang.Math.max; import static java.lang.Math.sqrt; import static java.lang.Math.pow; import static java.lang.Math.abs; import static java.lang.Integer.MIN_VALUE; import static java.lang.Integer.MAX_VALUE; public class Main { static boolean IS_LOCAL = false; static Fast f = new Fast(); static PrintWriter out = new PrintWriter(System.out); static boolean TEST_CASES = true; static int mod1 = (int)1e9+7; static int mod2 = 998244353; static void solve() { int n = ri(); int l = ri(), r = ri(); int sz = r-l+1; int[] anss = new int[n]; boolean ok = true; for(int i = 0; i < n && ok; i++) { int x = i+1; int ans = l; if(l%x!=0) ans += x-l%x; if(ans<=r) anss[i] = ans; else ok = false; } out.println(ok?"YES":"NO"); if(ok){ for(int i = 0; i < n; i++) { if(i>0) out.print(" "); out.print(anss[i]); } out.println(); } } public static void main(String[] args)throws Exception{ if(TEST_CASES){ int t = ri(); while(t-->0){ solve(); } } else { solve(); } out.close(); } static int nod(long l) { if(l>=1000000000000000000l) return 19; if(l>=100000000000000000l) return 18; if(l>=10000000000000000l) return 17; if(l>=1000000000000000l) return 16; if(l>=100000000000000l) return 15; if(l>=10000000000000l) return 14; if(l>=1000000000000l) return 13; if(l>=100000000000l) return 12; if(l>=10000000000l) return 11; if(l>=1000000000) return 10; if(l>=100000000) return 9; if(l>=10000000) return 8; if(l>=1000000) return 7; if(l>=100000) return 6; if(l>=10000) return 5; if(l>=1000) return 4; if(l>=100) return 3; if(l>=10) return 2; return 1; } static int ri() { return f.nextInt(); } static long rl() { return f.nextLong(); } static String rs(){ return f.next(); } static String rS(){ return f.nextLine(); } static char rc(){ return f.next().charAt(0); } static int[] ra(int n) { int[] a = new int[n]; for(int i = 0;i<n;i++) a[i] = ri(); return a; } static long[] ral(int n) { long[] a = new long[n]; for(int i = 0;i<n;i++) a[i] = rl(); return a; } static char[] rac(){ char[] c = rs().toCharArray(); return c; } static int[][] rm(int n, int m){ int[][] mat = new int[n][m]; for(int i = 0; i < n; i++) mat[i] = ra(m); return mat; } static char[][] rmc(int n){ char[][] cmat = new char[n][]; for(int i = 0; i < n;i++) cmat[i] = rac(); return cmat; } static void sort(int[] a) { ArrayList<Integer> list=new ArrayList<>(); for (int i:a) list.add(i); Collections.sort(list); for (int i=0; i<a.length; i++) a[i]=list.get(i); } static void sort(double[] a) { ArrayList<Double> list=new ArrayList<>(); for (double i:a) list.add(i); Collections.sort(list); for (int i=0; i<a.length; i++) a[i]=list.get(i); } static class Fast{ public BufferedReader br; public StringTokenizer st; public Fast(){ try{ br = IS_LOCAL? (new BufferedReader(new FileReader("input.txt"))):(new BufferedReader(new InputStreamReader(System.in))); } catch(Exception e){ throw new RuntimeException(e); } } String next(){ while(st==null || !st.hasMoreTokens()){ try{ st=new StringTokenizer(br.readLine()); } catch(IOException e){ throw new RuntimeException(e); } } 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 8
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
8dbb605776e407707ac0aef6cb3c577b
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 b { private static StreamTokenizer st; private static int nextInt() throws IOException{ st.nextToken(); return (int)st.nval; } public static void main(String[] args) throws IOException{ st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); int t = nextInt(); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); while(t-->0) { int n = nextInt(); long l = nextInt(), r = nextInt(); long a[] = new long[n]; boolean valid = true; for(int i = 1; i <= n; ++i) { //find if a multiple of i exist in l and r if((long)Math.ceil((double)l/i)*i>r) { valid = false; break; } a[i-1] = (long)Math.ceil((double)l/i)*i; } if(valid) { pw.println("YES"); pw.print(a[0]); for(int i = 1; i < n; ++i) pw.print(" " + a[i]); pw.println(); }else { pw.println("NO"); } } 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 8
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
1f42b40f54034e055a022c9c4ddcb987
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.io.File; /** * Created on 2022-07-16 22:34:05 * * @author macinchang */ public class A { public static void main(String[] args) throws Exception { Scanner scanner; if (System.getProperty("ONLINE_JUDGE") == null) { File inFile = new File("in.txt"); scanner = new Scanner(inFile); } else { scanner = new Scanner(System.in); } int t = scanner.nextInt(); Solver solver = new Solver(scanner); while (t-- > 0) { solver.solve(); } scanner.close(); } public static class Solver { private Scanner sc; Solver(Scanner scanner) { this.sc = scanner; } public void solve() { int n = sc.nextInt(), l = sc.nextInt(), r = sc.nextInt(); int[] a = new int[n + 1]; boolean f = false; for (int i = n; i >= 1; i--) { a[i] = i * ((l + i - 1) / i); if (a[i] > r) { f = true; break; } } if (f) { System.out.println("NO"); return; } System.out.println("YES"); for (int i = 1; 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 8
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