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
sequencelengths
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
4f0ab8ea90e00215fcded07b29c20a65
train_110.jsonl
1646408100
$$$ \def\myred#1{\color{red}{\underline{\bf{#1}}}} \def\myblue#1{\color{blue}{\overline{\bf{#1}}}} $$$ $$$\def\RED{\myred{Red}} \def\BLUE{\myblue{Blue}}$$$You are given a sequence of $$$n$$$ non-negative integers $$$a_1, a_2, \ldots, a_n$$$. Initially, all the elements of the sequence are unpainted. You can paint each number $$$\RED$$$ or $$$\BLUE$$$ (but not both), or leave it unpainted. For a color $$$c$$$, $$$\text{Count}(c)$$$ is the number of elements in the sequence painted with that color and $$$\text{Sum}(c)$$$ is the sum of the elements in the sequence painted with that color.For example, if the given sequence is $$$[2, 8, 6, 3, 1]$$$ and it is painted this way: $$$[\myblue{2}, 8, \myred{6}, \myblue{3}, 1]$$$ (where $$$6$$$ is painted red, $$$2$$$ and $$$3$$$ are painted blue, $$$1$$$ and $$$8$$$ are unpainted) then $$$\text{Sum}(\RED)=6$$$, $$$\text{Sum}(\BLUE)=2+3=5$$$, $$$\text{Count}(\RED)=1$$$, and $$$\text{Count}(\BLUE)=2$$$.Determine if it is possible to paint the sequence so that $$$\text{Sum}(\RED) > \text{Sum}(\BLUE)$$$ and $$$\text{Count}(\RED) < \text{Count}(\BLUE)$$$.
256 megabytes
import java.util.*; import java.io.*; public class quality_vs_quantity{ //your method here void quantityFirst(int n , int arr[]){ Arrays.sort(arr); int j=0; int k=n-1; long sumJ=arr[0]; long sumK=arr[n-1]; // System.out.println(Arrays.toString(arr)); while(j<k){ if(sumK > sumJ && (j+1) > (n-k)){ System.out.println("YES"); return; } // System.out.println(sumJ +" sum "+sumK); if(sumJ >= sumK){ k--; sumK+=arr[k]; }else{ j++; sumJ+=arr[j]; } // System.out.println(j+" "+k); } System.out.println("NO"); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int testCases=in.nextInt(); while(testCases-- > 0){ int n= in.nextInt(); int arr[]=new int[n]; for(int i=0; i<n; i++){ arr[i]=in.nextInt(); } quality_vs_quantity q = new quality_vs_quantity(); q.quantityFirst(n, arr); } } }
Java
["4\n3\n1 2 3\n5\n2 8 6 3 1\n4\n3 5 4 2\n5\n1000000000 1000000000 1000000000 1000000000 1000000000"]
2 seconds
["NO\nYES\nNO\nNO"]
NoteIn the first test case, there is no possible way to paint the sequence. For example, if you paint the sequence this way: $$$[\myblue{1},\myblue{2},\myred{3}]$$$ (where $$$3$$$ is painted red, $$$1$$$ and $$$2$$$ are painted blue) then $$$\text{Count}(\RED)=1 &lt; \text{Count}(\BLUE)=2$$$, but $$$\text{Sum}(\RED)=3 \ngtr \text{Sum}(\BLUE)=3$$$. So, this is not a possible way to paint the sequence.In the second test case, a possible way to paint the sequence is described in the statement. We can see that $$$\text{Sum}(\RED)=6 &gt; \text{Sum}(\BLUE)=5$$$ and $$$\text{Count}(\RED)=1 &lt; \text{Count}(\BLUE)=2$$$.In the third test case, there is no possible way to paint the sequence. For example, if you paint the sequence this way: $$$[\myred{3},\myred{5},\myblue{4}, \myblue{2}]$$$ (where $$$3$$$ and $$$5$$$ are painted red, $$$4$$$ and $$$2$$$ are painted blue) then $$$\text{Sum}(\RED) = 8 &gt; \text{Sum}(\BLUE) = 6$$$ but $$$\text{Count}(\RED) = 2 \nless \text{Count}(\BLUE) = 2$$$. So, this is not a possible way to paint the sequence.In the fourth test case, it can be proven that there is no possible way to paint the sequence satisfying sum and count constraints.
Java 17
standard input
[ "brute force", "constructive algorithms", "greedy", "sortings", "two pointers" ]
4af59df1bc56ca8eb5913c2e57905922
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3\le n\le 2\cdot 10^5$$$) — the length of the given sequence. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$0\le a_i\le 10^9$$$) — the given sequence. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
800
For each test case, print YES if it is possible to paint the given sequence satisfying the above requirements, and NO otherwise. You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).
standard output
PASSED
e404df0563d72a895fa2e330df61c870
train_110.jsonl
1646408100
$$$ \def\myred#1{\color{red}{\underline{\bf{#1}}}} \def\myblue#1{\color{blue}{\overline{\bf{#1}}}} $$$ $$$\def\RED{\myred{Red}} \def\BLUE{\myblue{Blue}}$$$You are given a sequence of $$$n$$$ non-negative integers $$$a_1, a_2, \ldots, a_n$$$. Initially, all the elements of the sequence are unpainted. You can paint each number $$$\RED$$$ or $$$\BLUE$$$ (but not both), or leave it unpainted. For a color $$$c$$$, $$$\text{Count}(c)$$$ is the number of elements in the sequence painted with that color and $$$\text{Sum}(c)$$$ is the sum of the elements in the sequence painted with that color.For example, if the given sequence is $$$[2, 8, 6, 3, 1]$$$ and it is painted this way: $$$[\myblue{2}, 8, \myred{6}, \myblue{3}, 1]$$$ (where $$$6$$$ is painted red, $$$2$$$ and $$$3$$$ are painted blue, $$$1$$$ and $$$8$$$ are unpainted) then $$$\text{Sum}(\RED)=6$$$, $$$\text{Sum}(\BLUE)=2+3=5$$$, $$$\text{Count}(\RED)=1$$$, and $$$\text{Count}(\BLUE)=2$$$.Determine if it is possible to paint the sequence so that $$$\text{Sum}(\RED) &gt; \text{Sum}(\BLUE)$$$ and $$$\text{Count}(\RED) &lt; \text{Count}(\BLUE)$$$.
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Array; import java.util.Arrays; import java.util.Dictionary; import java.util.Hashtable; import java.util.Map; public class Main { static class InputReader { /** * The default size of the InputReader's buffer is 2<sup>16</sup>. */ private static final int DEFAULT_BUFFER_SIZE = 1 << 16; /** * The default stream for the InputReader is standard input. */ private static final InputStream DEFAULT_STREAM = System.in; /** * The maximum number of accurate decimal digits the method {@link #nextDoubleFast() nextDoubleFast()} can read. * Currently this value is set to 21 because it is the maximum number of digits a double precision float can have at the moment. */ private static final int MAX_DECIMAL_PRECISION = 21; // 'c' is used to refer to the current character in the stream private int c; // Variables associated with the byte buffer. private byte[] buf; private int bufferSize, bufIndex, numBytesRead; private InputStream stream; // End Of File (EOF) character private static final byte EOF = -1; // New line character: '\n' private static final byte NEW_LINE = 10; // Space character: ' ' private static final byte SPACE = 32; // Dash character: '-' private static final byte DASH = 45; // Dot character: '.' private static final byte DOT = 46; // A reusable character buffer when reading string data. private char[] charBuffer; // Primitive data type lookup tables used for optimizations private static byte[] bytes = new byte[58]; private static int[] ints = new int[58]; private static char[] chars = new char[128]; static { char ch = ' '; int value = 0; byte _byte = 0; for (int i = 48; i < 58; i++) bytes[i] = _byte++; for (int i = 48; i < 58; i++) ints[i] = value++; for (int i = 32; i < 128; i++) chars[i] = ch++; } // Primitive double lookup table used for optimizations. private static final double[][] doubles = { {0.0d, 0.00d, 0.000d, 0.0000d, 0.00000d, 0.000000d, 0.0000000d, 0.00000000d, 0.000000000d, 0.0000000000d, 0.00000000000d, 0.000000000000d, 0.0000000000000d, 0.00000000000000d, 0.000000000000000d, 0.0000000000000000d, 0.00000000000000000d, 0.000000000000000000d, 0.0000000000000000000d, 0.00000000000000000000d, 0.000000000000000000000d}, {0.1d, 0.01d, 0.001d, 0.0001d, 0.00001d, 0.000001d, 0.0000001d, 0.00000001d, 0.000000001d, 0.0000000001d, 0.00000000001d, 0.000000000001d, 0.0000000000001d, 0.00000000000001d, 0.000000000000001d, 0.0000000000000001d, 0.00000000000000001d, 0.000000000000000001d, 0.0000000000000000001d, 0.00000000000000000001d, 0.000000000000000000001d}, {0.2d, 0.02d, 0.002d, 0.0002d, 0.00002d, 0.000002d, 0.0000002d, 0.00000002d, 0.000000002d, 0.0000000002d, 0.00000000002d, 0.000000000002d, 0.0000000000002d, 0.00000000000002d, 0.000000000000002d, 0.0000000000000002d, 0.00000000000000002d, 0.000000000000000002d, 0.0000000000000000002d, 0.00000000000000000002d, 0.000000000000000000002d}, {0.3d, 0.03d, 0.003d, 0.0003d, 0.00003d, 0.000003d, 0.0000003d, 0.00000003d, 0.000000003d, 0.0000000003d, 0.00000000003d, 0.000000000003d, 0.0000000000003d, 0.00000000000003d, 0.000000000000003d, 0.0000000000000003d, 0.00000000000000003d, 0.000000000000000003d, 0.0000000000000000003d, 0.00000000000000000003d, 0.000000000000000000003d}, {0.4d, 0.04d, 0.004d, 0.0004d, 0.00004d, 0.000004d, 0.0000004d, 0.00000004d, 0.000000004d, 0.0000000004d, 0.00000000004d, 0.000000000004d, 0.0000000000004d, 0.00000000000004d, 0.000000000000004d, 0.0000000000000004d, 0.00000000000000004d, 0.000000000000000004d, 0.0000000000000000004d, 0.00000000000000000004d, 0.000000000000000000004d}, {0.5d, 0.05d, 0.005d, 0.0005d, 0.00005d, 0.000005d, 0.0000005d, 0.00000005d, 0.000000005d, 0.0000000005d, 0.00000000005d, 0.000000000005d, 0.0000000000005d, 0.00000000000005d, 0.000000000000005d, 0.0000000000000005d, 0.00000000000000005d, 0.000000000000000005d, 0.0000000000000000005d, 0.00000000000000000005d, 0.000000000000000000005d}, {0.6d, 0.06d, 0.006d, 0.0006d, 0.00006d, 0.000006d, 0.0000006d, 0.00000006d, 0.000000006d, 0.0000000006d, 0.00000000006d, 0.000000000006d, 0.0000000000006d, 0.00000000000006d, 0.000000000000006d, 0.0000000000000006d, 0.00000000000000006d, 0.000000000000000006d, 0.0000000000000000006d, 0.00000000000000000006d, 0.000000000000000000006d}, {0.7d, 0.07d, 0.007d, 0.0007d, 0.00007d, 0.000007d, 0.0000007d, 0.00000007d, 0.000000007d, 0.0000000007d, 0.00000000007d, 0.000000000007d, 0.0000000000007d, 0.00000000000007d, 0.000000000000007d, 0.0000000000000007d, 0.00000000000000007d, 0.000000000000000007d, 0.0000000000000000007d, 0.00000000000000000007d, 0.000000000000000000007d}, {0.8d, 0.08d, 0.008d, 0.0008d, 0.00008d, 0.000008d, 0.0000008d, 0.00000008d, 0.000000008d, 0.0000000008d, 0.00000000008d, 0.000000000008d, 0.0000000000008d, 0.00000000000008d, 0.000000000000008d, 0.0000000000000008d, 0.00000000000000008d, 0.000000000000000008d, 0.0000000000000000008d, 0.00000000000000000008d, 0.000000000000000000008d}, {0.9d, 0.09d, 0.009d, 0.0009d, 0.00009d, 0.000009d, 0.0000009d, 0.00000009d, 0.000000009d, 0.0000000009d, 0.00000000009d, 0.000000000009d, 0.0000000000009d, 0.00000000000009d, 0.000000000000009d, 0.0000000000000009d, 0.00000000000000009d, 0.000000000000000009d, 0.0000000000000000009d, 0.00000000000000000009d, 0.000000000000000000009d} }; /** * Create an InputReader that reads from standard input. */ public InputReader() { this(DEFAULT_STREAM, DEFAULT_BUFFER_SIZE); } /** * Create an InputReader that reads from standard input. * * @param bufferSize The buffer size for this input reader. */ public InputReader(int bufferSize) { this(DEFAULT_STREAM, bufferSize); } /** * Create an InputReader that reads from standard input. * * @param stream Takes an InputStream as a parameter to read from. */ public InputReader(InputStream stream) { this(stream, DEFAULT_BUFFER_SIZE); } /** * Create an InputReader that reads from standard input. * * @param stream Takes an {@link java.io.InputStream#InputStream() InputStream} as a parameter to read from. * @param bufferSize The size of the buffer to use. */ public InputReader(InputStream stream, int bufferSize) { if (stream == null || bufferSize <= 0) throw new IllegalArgumentException(); buf = new byte[bufferSize]; charBuffer = new char[128]; this.bufferSize = bufferSize; this.stream = stream; } /** * Reads a single character from the input stream. * * @return Returns the byte value of the next character in the buffer and EOF * at the end of the stream. * @throws IOException throws exception if there is no more data to read */ private byte read() throws IOException { if (numBytesRead == EOF) throw new IOException(); if (bufIndex >= numBytesRead) { bufIndex = 0; numBytesRead = stream.read(buf); if (numBytesRead == EOF) return EOF; } return buf[bufIndex++]; } /** * Read values from the input stream until you reach a character with a * higher ASCII value than 'token'. * * @param token The token is a value which we use to stop reading junk out of * the stream. * @return Returns 0 if a value greater than the token was reached or -1 if * the end of the stream was reached. * @throws IOException Throws exception at end of stream. */ private int readJunk(int token) throws IOException { if (numBytesRead == EOF) return EOF; // Seek to the first valid position index do { while (bufIndex < numBytesRead) { if (buf[bufIndex] > token) return 0; bufIndex++; } // reload buffer numBytesRead = stream.read(buf); if (numBytesRead == EOF) return EOF; bufIndex = 0; } while (true); } /** * Reads a single byte from the input stream. * * @return The next byte in the input stream * @throws IOException Throws exception at end of stream. */ public byte nextByte() throws IOException { return (byte) nextInt(); } /** * Reads a 32 bit signed integer from input stream. * * @return The next integer value in the stream. * @throws IOException Throws exception at end of stream. */ public int nextInt() throws IOException { if (readJunk(DASH - 1) == EOF) throw new IOException(); int sgn = 1, res = 0; c = buf[bufIndex]; if (c == DASH) { sgn = -1; bufIndex++; } do { while (bufIndex < numBytesRead) { if (buf[bufIndex] > SPACE) { res = (res << 3) + (res << 1); res += ints[buf[bufIndex++]]; } else { bufIndex++; return res * sgn; } } // Reload buffer numBytesRead = stream.read(buf); if (numBytesRead == EOF) return res * sgn; bufIndex = 0; } while (true); } /** * Reads a 64 bit signed long from input stream. * * @return The next long value in the stream. * @throws IOException Throws exception at end of stream. */ public long nextLong() throws IOException { if (readJunk(DASH - 1) == EOF) throw new IOException(); int sgn = 1; long res = 0L; c = buf[bufIndex]; if (c == DASH) { sgn = -1; bufIndex++; } do { while (bufIndex < numBytesRead) { if (buf[bufIndex] > SPACE) { res = (res << 3) + (res << 1); res += ints[buf[bufIndex++]]; } else { bufIndex++; return res * sgn; } } // Reload buffer numBytesRead = stream.read(buf); if (numBytesRead == EOF) return res * sgn; bufIndex = 0; } while (true); } /** * Doubles the size of the internal char buffer for strings */ private void doubleCharBufferSize() { char[] newBuffer = new char[charBuffer.length << 1]; for (int i = 0; i < charBuffer.length; i++) newBuffer[i] = charBuffer[i]; charBuffer = newBuffer; } /** * Reads a line from the input stream. * * @return Returns a line from the input stream in the form a String not * including the new line character. Returns <code>null</code> when there are * no more lines. * @throws IOException Throws IOException when something terrible happens. */ public String nextLine() throws IOException { try { c = read(); } catch (IOException e) { return null; } if (c == NEW_LINE) return ""; // Empty line if (c == EOF) return null; // EOF int i = 0; charBuffer[i++] = (char) c; do { while (bufIndex < numBytesRead) { if (buf[bufIndex] != NEW_LINE) { if (i == charBuffer.length) doubleCharBufferSize(); charBuffer[i++] = (char) buf[bufIndex++]; } else { bufIndex++; return new String(charBuffer, 0, i); } } // Reload buffer numBytesRead = stream.read(buf); if (numBytesRead == EOF) return new String(charBuffer, 0, i); bufIndex = 0; } while (true); } // Reads a string of characters from the input stream. // The delimiter separating a string of characters is set to be: // any ASCII value <= 32 meaning any spaces, new lines, EOF, tabs... public String nextString() throws IOException { if (numBytesRead == EOF) return null; if (readJunk(SPACE) == EOF) return null; for (int i = 0; ; ) { while (bufIndex < numBytesRead) { if (buf[bufIndex] > SPACE) { if (i == charBuffer.length) doubleCharBufferSize(); charBuffer[i++] = (char) buf[bufIndex++]; } else { bufIndex++; return new String(charBuffer, 0, i); } } // Reload buffer numBytesRead = stream.read(buf); if (numBytesRead == EOF) return new String(charBuffer, 0, i); bufIndex = 0; } } // Returns an exact value a double value from the input stream. public double nextDouble() throws IOException { String doubleVal = nextString(); if (doubleVal == null) throw new IOException(); return Double.valueOf(doubleVal); } // Very quickly reads a double value from the input stream (~3x faster than nextDouble()). However, // this method may provide a slightly less accurate reading than .nextDouble() if there are a lot // of digits (~16+). In particular, it will only read double values with at most 21 digits after // the decimal point and the reading my be as inaccurate as ~5*10^-16 from the true value. public double nextDoubleFast() throws IOException { c = read(); int sgn = 1; while (c <= SPACE) c = read(); // while c is either: ' ', '\n', EOF if (c == DASH) { sgn = -1; c = read(); } double res = 0.0; // while c is not: ' ', '\n', '.' or -1 while (c > DOT) { res *= 10.0; res += ints[c]; c = read(); } if (c == DOT) { int i = 0; c = read(); // while c is digit and we are less than the maximum decimal precision while (c > SPACE && i < MAX_DECIMAL_PRECISION) { res += doubles[ints[c]][i++]; c = read(); } } return res * sgn; } // Read an array of n byte values public byte[] nextByteArray(int n) throws IOException { byte[] ar = new byte[n]; for (int i = 0; i < n; i++) ar[i] = nextByte(); return ar; } // Read an integer array of size n public int[] nextIntArray(int n) throws IOException { int[] ar = new int[n]; for (int i = 0; i < n; i++) ar[i] = nextInt(); return ar; } // Read a long array of size n public long[] nextLongArray(int n) throws IOException { long[] ar = new long[n]; for (int i = 0; i < n; i++) ar[i] = nextLong(); return ar; } // read an of doubles of size n public double[] nextDoubleArray(int n) throws IOException { double[] ar = new double[n]; for (int i = 0; i < n; i++) ar[i] = nextDouble(); return ar; } // Quickly read an array of doubles public double[] nextDoubleArrayFast(int n) throws IOException { double[] ar = new double[n]; for (int i = 0; i < n; i++) ar[i] = nextDoubleFast(); return ar; } // Read a string array of size n public String[] nextStringArray(int n) throws IOException { String[] ar = new String[n]; for (int i = 0; i < n; i++) { String str = nextString(); if (str == null) throw new IOException(); ar[i] = str; } return ar; } // Read a 1-based byte array of size n+1 public byte[] nextByteArray1(int n) throws IOException { byte[] ar = new byte[n + 1]; for (int i = 1; i <= n; i++) ar[i] = nextByte(); return ar; } // Read a 1-based integer array of size n+1 public int[] nextIntArray1(int n) throws IOException { int[] ar = new int[n + 1]; for (int i = 1; i <= n; i++) ar[i] = nextInt(); return ar; } // Read a 1-based long array of size n+1 public long[] nextLongArray1(int n) throws IOException { long[] ar = new long[n + 1]; for (int i = 1; i <= n; i++) ar[i] = nextLong(); return ar; } // Read a 1-based double array of size n+1 public double[] nextDoubleArray1(int n) throws IOException { double[] ar = new double[n + 1]; for (int i = 1; i <= n; i++) ar[i] = nextDouble(); return ar; } // Quickly read a 1-based double array of size n+1 public double[] nextDoubleArrayFast1(int n) throws IOException { double[] ar = new double[n + 1]; for (int i = 1; i <= n; i++) ar[i] = nextDoubleFast(); return ar; } // Read a 1-based string array of size n+1 public String[] nextStringArray1(int n) throws IOException { String[] ar = new String[n + 1]; for (int i = 1; i <= n; i++) ar[i] = nextString(); return ar; } // Read a two dimensional matrix of bytes of size rows x cols public byte[][] nextByteMatrix(int rows, int cols) throws IOException { byte[][] matrix = new byte[rows][cols]; for (int i = 0; i < rows; i++) for (int j = 0; j < cols; j++) matrix[i][j] = nextByte(); return matrix; } // Read a two dimensional matrix of ints of size rows x cols public int[][] nextIntMatrix(int rows, int cols) throws IOException { int[][] matrix = new int[rows][cols]; for (int i = 0; i < rows; i++) for (int j = 0; j < cols; j++) matrix[i][j] = nextInt(); return matrix; } // Read a two dimensional matrix of longs of size rows x cols public long[][] nextLongMatrix(int rows, int cols) throws IOException { long[][] matrix = new long[rows][cols]; for (int i = 0; i < rows; i++) for (int j = 0; j < cols; j++) matrix[i][j] = nextLong(); return matrix; } // Read a two dimensional matrix of doubles of size rows x cols public double[][] nextDoubleMatrix(int rows, int cols) throws IOException { double[][] matrix = new double[rows][cols]; for (int i = 0; i < rows; i++) for (int j = 0; j < cols; j++) matrix[i][j] = nextDouble(); return matrix; } // Quickly read a two dimensional matrix of doubles of size rows x cols public double[][] nextDoubleMatrixFast(int rows, int cols) throws IOException { double[][] matrix = new double[rows][cols]; for (int i = 0; i < rows; i++) for (int j = 0; j < cols; j++) matrix[i][j] = nextDoubleFast(); return matrix; } // Read a two dimensional matrix of Strings of size rows x cols public String[][] nextStringMatrix(int rows, int cols) throws IOException { String[][] matrix = new String[rows][cols]; for (int i = 0; i < rows; i++) for (int j = 0; j < cols; j++) matrix[i][j] = nextString(); return matrix; } // Read a 1-based two dimensional matrix of bytes of size rows x cols public byte[][] nextByteMatrix1(int rows, int cols) throws IOException { byte[][] matrix = new byte[rows + 1][cols + 1]; for (int i = 1; i <= rows; i++) for (int j = 1; j <= cols; j++) matrix[i][j] = nextByte(); return matrix; } // Read a 1-based two dimensional matrix of ints of size rows x cols public int[][] nextIntMatrix1(int rows, int cols) throws IOException { int[][] matrix = new int[rows + 1][cols + 1]; for (int i = 1; i <= rows; i++) for (int j = 1; j <= cols; j++) matrix[i][j] = nextInt(); return matrix; } // Read a 1-based two dimensional matrix of longs of size rows x cols public long[][] nextLongMatrix1(int rows, int cols) throws IOException { long[][] matrix = new long[rows + 1][cols + 1]; for (int i = 1; i <= rows; i++) for (int j = 1; j <= cols; j++) matrix[i][j] = nextLong(); return matrix; } // Read a 1-based two dimensional matrix of doubles of size rows x cols public double[][] nextDoubleMatrix1(int rows, int cols) throws IOException { double[][] matrix = new double[rows + 1][cols + 1]; for (int i = 1; i <= rows; i++) for (int j = 1; j <= cols; j++) matrix[i][j] = nextDouble(); return matrix; } // Quickly read a 1-based two dimensional matrix of doubles of size rows x cols public double[][] nextDoubleMatrixFast1(int rows, int cols) throws IOException { double[][] matrix = new double[rows + 1][cols + 1]; for (int i = 1; i <= rows; i++) for (int j = 1; j <= cols; j++) matrix[i][j] = nextDoubleFast(); return matrix; } // Read a 1-based two dimensional matrix of Strings of size rows x cols public String[][] nextStringMatrix1(int rows, int cols) throws IOException { String[][] matrix = new String[rows + 1][cols + 1]; for (int i = 1; i <= rows; i++) for (int j = 1; j <= cols; j++) matrix[i][j] = nextString(); return matrix; } // Closes the input stream public void close() throws IOException { stream.close(); } } static InputReader read = new InputReader(); public static void main(String[] args) throws IOException { int t = read.nextInt(); while (t-->0){ int n = read.nextInt(); int[] array = read.nextIntArray(n); Arrays.sort(array); int i = 2; int j = n - 2; long sumJ = array[n-1]; long sumI = array[0] + array[1]; while (i < j){ if(sumJ > sumI) break; sumJ+=array[j--]; sumI+=array[i++]; } System.out.println((sumJ > sumI)?"YES":"NO"); } } public static int getIthBit(int n,int i){ return ((n & (1<<i) ) > 0 ? 1:0); } public static int setIthBit(int n,int i){ return (n | (1 << i)); } public static int clearIthBit(int n,int i){ return (n & (~ (1 << i))); } public static int updateIthBit(int n,int i, int value){ if(value == 1) return setIthBit(n,i); return clearIthBit(n,i); } public static int clearLastIBits(int n,int i){ return n & (-1<<i); } } class SegmentTree{ long[] array; long[] lazy; int n; SegmentTree(long[] array){ n = array.length; this.array = new long[n * 4]; lazy = new long[n * 4]; build(0,n - 1,0,array); } SegmentTree(int n){ this.n =n; array = new long[n * 4]; lazy = new long[n * 4]; } private void build(int start, int end,int node,long[] array){ // leaf node case if(start == end){ this.array[node] = array[end]; return; } int mid = (start + end) / 2; // left subTree (0 , mid) build(start,mid, 2 * node + 1,array); // right subTree (mid+1,end) build(mid+1,end, 2 * node + 2,array); // here is what to store in a parent node this.array[node] = this.array[node * 2 + 1] + this.array[node * 2 + 2]; } private long query(int start, int end,int l,int r,int node){ clearLazy(start, end, node); // non overlapping case if(start >r || end < l)return 0; // complete overlap if(start>=l && end<=r)return array[node]; //partial overlap int mid = (start + end) / 2; long left = query(start,mid,l,r,node * 2 + 1); long right = query(mid+1,end,l,r,node * 2 + 2); return left+right; } public long query(int l,int r){ return query(0,n-1,l,r,0); } private void update(int start,int end,int node,int l,int r,long value){ clearLazy(start, end, node); // non overlapping case if(start > r || end < l)return; // complete overlap if(start>=l && end<=r){ array[node] += value * (end - start + 1); if(start != end){ lazy[node * 2 + 1] +=value; lazy[node * 2 + 2] +=value; } return; } // partial case int mid = (start + end) / 2; update(start,mid,node * 2 + 1,l,r,value); update(mid+1,end,node * 2 + 2,l,r,value); array[node] = array[node * 2 + 1] +array[node * 2 + 2]; } private void clearLazy(int start, int end, int node) { if(lazy[node] != 0) {// pending update array[node] += (lazy[node] * (end - start + 1)); // if not a leaf node add the value to its children if(start != end){ lazy[node * 2 + 1] += lazy[node]; lazy[node * 2 + 2] += lazy[node]; } lazy[node] = 0; } } public void update(int l,int r,int value){ update(0,n-1,0,l,r,value); } }
Java
["4\n3\n1 2 3\n5\n2 8 6 3 1\n4\n3 5 4 2\n5\n1000000000 1000000000 1000000000 1000000000 1000000000"]
2 seconds
["NO\nYES\nNO\nNO"]
NoteIn the first test case, there is no possible way to paint the sequence. For example, if you paint the sequence this way: $$$[\myblue{1},\myblue{2},\myred{3}]$$$ (where $$$3$$$ is painted red, $$$1$$$ and $$$2$$$ are painted blue) then $$$\text{Count}(\RED)=1 &lt; \text{Count}(\BLUE)=2$$$, but $$$\text{Sum}(\RED)=3 \ngtr \text{Sum}(\BLUE)=3$$$. So, this is not a possible way to paint the sequence.In the second test case, a possible way to paint the sequence is described in the statement. We can see that $$$\text{Sum}(\RED)=6 &gt; \text{Sum}(\BLUE)=5$$$ and $$$\text{Count}(\RED)=1 &lt; \text{Count}(\BLUE)=2$$$.In the third test case, there is no possible way to paint the sequence. For example, if you paint the sequence this way: $$$[\myred{3},\myred{5},\myblue{4}, \myblue{2}]$$$ (where $$$3$$$ and $$$5$$$ are painted red, $$$4$$$ and $$$2$$$ are painted blue) then $$$\text{Sum}(\RED) = 8 &gt; \text{Sum}(\BLUE) = 6$$$ but $$$\text{Count}(\RED) = 2 \nless \text{Count}(\BLUE) = 2$$$. So, this is not a possible way to paint the sequence.In the fourth test case, it can be proven that there is no possible way to paint the sequence satisfying sum and count constraints.
Java 17
standard input
[ "brute force", "constructive algorithms", "greedy", "sortings", "two pointers" ]
4af59df1bc56ca8eb5913c2e57905922
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3\le n\le 2\cdot 10^5$$$) — the length of the given sequence. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$0\le a_i\le 10^9$$$) — the given sequence. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
800
For each test case, print YES if it is possible to paint the given sequence satisfying the above requirements, and NO otherwise. You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).
standard output
PASSED
a3dfa3db96651ba35ff165d1a12b6b66
train_110.jsonl
1646408100
$$$ \def\myred#1{\color{red}{\underline{\bf{#1}}}} \def\myblue#1{\color{blue}{\overline{\bf{#1}}}} $$$ $$$\def\RED{\myred{Red}} \def\BLUE{\myblue{Blue}}$$$You are given a sequence of $$$n$$$ non-negative integers $$$a_1, a_2, \ldots, a_n$$$. Initially, all the elements of the sequence are unpainted. You can paint each number $$$\RED$$$ or $$$\BLUE$$$ (but not both), or leave it unpainted. For a color $$$c$$$, $$$\text{Count}(c)$$$ is the number of elements in the sequence painted with that color and $$$\text{Sum}(c)$$$ is the sum of the elements in the sequence painted with that color.For example, if the given sequence is $$$[2, 8, 6, 3, 1]$$$ and it is painted this way: $$$[\myblue{2}, 8, \myred{6}, \myblue{3}, 1]$$$ (where $$$6$$$ is painted red, $$$2$$$ and $$$3$$$ are painted blue, $$$1$$$ and $$$8$$$ are unpainted) then $$$\text{Sum}(\RED)=6$$$, $$$\text{Sum}(\BLUE)=2+3=5$$$, $$$\text{Count}(\RED)=1$$$, and $$$\text{Count}(\BLUE)=2$$$.Determine if it is possible to paint the sequence so that $$$\text{Sum}(\RED) &gt; \text{Sum}(\BLUE)$$$ and $$$\text{Count}(\RED) &lt; \text{Count}(\BLUE)$$$.
256 megabytes
//package cf; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.*; import java.util.StringTokenizer; public class cftt { 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) {} return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } } public static void debug(int mat[][]) { for(int i=0; i<mat.length; i++) { System.out.print(mat[i][0]+" "+mat[i][1]); System.out.println(); } } public static void main(String[] args) { FastScanner r = new FastScanner(); PrintWriter out=new PrintWriter(System.out); // System.out.println("input"); int tc=r.nextInt(); while(tc-->0) { int n=r.nextInt(); long x[]=new long[n]; for(int i=0; i<n; i++)x[i]=r.nextLong(); Arrays.sort(x); long pref[]=new long[n]; long suff[]=new long[n]; suff[n-1]=x[0]; for(int i=n-2; i>=0; i--)suff[i]=suff[i+1]+x[n-i-1]; pref[0]=x[n-1]; for(int i=1; i<n; ++i) { pref[i]=pref[i-1]+x[n-i-1]; } // System.out.println(Arrays.toString(pref)); //System.out.println(Arrays.toString(suff)); boolean f=false; for(int i=0,j=n-2; i<j; i++,j--) { if(pref[i]>suff[j]) { f=true; break; } } if(f)out.println("YES"); else out.println("NO"); } out.close(); } } class pair{ int x; int y; int cost; public pair(int x,int y,int cost) { this.x=x; this.y=y; this.cost=cost; } }
Java
["4\n3\n1 2 3\n5\n2 8 6 3 1\n4\n3 5 4 2\n5\n1000000000 1000000000 1000000000 1000000000 1000000000"]
2 seconds
["NO\nYES\nNO\nNO"]
NoteIn the first test case, there is no possible way to paint the sequence. For example, if you paint the sequence this way: $$$[\myblue{1},\myblue{2},\myred{3}]$$$ (where $$$3$$$ is painted red, $$$1$$$ and $$$2$$$ are painted blue) then $$$\text{Count}(\RED)=1 &lt; \text{Count}(\BLUE)=2$$$, but $$$\text{Sum}(\RED)=3 \ngtr \text{Sum}(\BLUE)=3$$$. So, this is not a possible way to paint the sequence.In the second test case, a possible way to paint the sequence is described in the statement. We can see that $$$\text{Sum}(\RED)=6 &gt; \text{Sum}(\BLUE)=5$$$ and $$$\text{Count}(\RED)=1 &lt; \text{Count}(\BLUE)=2$$$.In the third test case, there is no possible way to paint the sequence. For example, if you paint the sequence this way: $$$[\myred{3},\myred{5},\myblue{4}, \myblue{2}]$$$ (where $$$3$$$ and $$$5$$$ are painted red, $$$4$$$ and $$$2$$$ are painted blue) then $$$\text{Sum}(\RED) = 8 &gt; \text{Sum}(\BLUE) = 6$$$ but $$$\text{Count}(\RED) = 2 \nless \text{Count}(\BLUE) = 2$$$. So, this is not a possible way to paint the sequence.In the fourth test case, it can be proven that there is no possible way to paint the sequence satisfying sum and count constraints.
Java 17
standard input
[ "brute force", "constructive algorithms", "greedy", "sortings", "two pointers" ]
4af59df1bc56ca8eb5913c2e57905922
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3\le n\le 2\cdot 10^5$$$) — the length of the given sequence. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$0\le a_i\le 10^9$$$) — the given sequence. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
800
For each test case, print YES if it is possible to paint the given sequence satisfying the above requirements, and NO otherwise. You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).
standard output
PASSED
9b02e615f600700e88a19e65d4cdd78a
train_110.jsonl
1646408100
$$$ \def\myred#1{\color{red}{\underline{\bf{#1}}}} \def\myblue#1{\color{blue}{\overline{\bf{#1}}}} $$$ $$$\def\RED{\myred{Red}} \def\BLUE{\myblue{Blue}}$$$You are given a sequence of $$$n$$$ non-negative integers $$$a_1, a_2, \ldots, a_n$$$. Initially, all the elements of the sequence are unpainted. You can paint each number $$$\RED$$$ or $$$\BLUE$$$ (but not both), or leave it unpainted. For a color $$$c$$$, $$$\text{Count}(c)$$$ is the number of elements in the sequence painted with that color and $$$\text{Sum}(c)$$$ is the sum of the elements in the sequence painted with that color.For example, if the given sequence is $$$[2, 8, 6, 3, 1]$$$ and it is painted this way: $$$[\myblue{2}, 8, \myred{6}, \myblue{3}, 1]$$$ (where $$$6$$$ is painted red, $$$2$$$ and $$$3$$$ are painted blue, $$$1$$$ and $$$8$$$ are unpainted) then $$$\text{Sum}(\RED)=6$$$, $$$\text{Sum}(\BLUE)=2+3=5$$$, $$$\text{Count}(\RED)=1$$$, and $$$\text{Count}(\BLUE)=2$$$.Determine if it is possible to paint the sequence so that $$$\text{Sum}(\RED) &gt; \text{Sum}(\BLUE)$$$ and $$$\text{Count}(\RED) &lt; \text{Count}(\BLUE)$$$.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class qualityQuantity { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int k=0;k<t;k++){ int n=sc.nextInt(); long[] arr=new long[n]; for(int i=0;i<n;i++){ arr[i]=sc.nextLong(); } Arrays.sort(arr); int start=0, end=n-1; int CR=1,CB=1; long SR=arr[end],SB=arr[start]; boolean res=false; while(start<end){ if(CB==CR&&SR>=SB){ CB++; start++; SB+=arr[start]; } else if(CB>CR&&SR<=SB){ CR++; end--; SR+=arr[end]; } else if(CB>CR&&SR>SB){ res=true; break; } } if(res) System.out.println("YES"); else System.out.println("NO"); } } }
Java
["4\n3\n1 2 3\n5\n2 8 6 3 1\n4\n3 5 4 2\n5\n1000000000 1000000000 1000000000 1000000000 1000000000"]
2 seconds
["NO\nYES\nNO\nNO"]
NoteIn the first test case, there is no possible way to paint the sequence. For example, if you paint the sequence this way: $$$[\myblue{1},\myblue{2},\myred{3}]$$$ (where $$$3$$$ is painted red, $$$1$$$ and $$$2$$$ are painted blue) then $$$\text{Count}(\RED)=1 &lt; \text{Count}(\BLUE)=2$$$, but $$$\text{Sum}(\RED)=3 \ngtr \text{Sum}(\BLUE)=3$$$. So, this is not a possible way to paint the sequence.In the second test case, a possible way to paint the sequence is described in the statement. We can see that $$$\text{Sum}(\RED)=6 &gt; \text{Sum}(\BLUE)=5$$$ and $$$\text{Count}(\RED)=1 &lt; \text{Count}(\BLUE)=2$$$.In the third test case, there is no possible way to paint the sequence. For example, if you paint the sequence this way: $$$[\myred{3},\myred{5},\myblue{4}, \myblue{2}]$$$ (where $$$3$$$ and $$$5$$$ are painted red, $$$4$$$ and $$$2$$$ are painted blue) then $$$\text{Sum}(\RED) = 8 &gt; \text{Sum}(\BLUE) = 6$$$ but $$$\text{Count}(\RED) = 2 \nless \text{Count}(\BLUE) = 2$$$. So, this is not a possible way to paint the sequence.In the fourth test case, it can be proven that there is no possible way to paint the sequence satisfying sum and count constraints.
Java 17
standard input
[ "brute force", "constructive algorithms", "greedy", "sortings", "two pointers" ]
4af59df1bc56ca8eb5913c2e57905922
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3\le n\le 2\cdot 10^5$$$) — the length of the given sequence. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$0\le a_i\le 10^9$$$) — the given sequence. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
800
For each test case, print YES if it is possible to paint the given sequence satisfying the above requirements, and NO otherwise. You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).
standard output
PASSED
2a3c12a5124f09b20e8723bf7bdc0971
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class CodeForces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); long n; String s; for (int i = 0; i < t; i++) { n = sc.nextInt(); s = sc.nextLine().substring(1); System.out.println(Long.parseLong(s) / (long) Math.pow(n, 2)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
f50d388f5b21abbdc43ccaf44d0c29c2
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class CodeForces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); long n, count = 0; String s; for (int i = 0; i < t; i++) { n = sc.nextInt(); s = sc.nextLine(); s = s.substring(1); count = Long.parseLong(s) / (long) Math.pow(n, 2); System.out.println(count); count = 0; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
712fdaafef32cc6bac427307a7d36d7c
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class CodeForces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); long n, count = 0, quintillion = Long.parseLong("100000000000000000"); int quintCount = 0; long percentage = 0; String s; for (int i = 0; i < t; i++) { n = sc.nextInt(); s = sc.nextLine(); s = s.substring(1); /* if (s.length() == 18) { quintCount = Character.getNumericValue(s.charAt(0)); for (int j = 0; j < quintCount; j++) { count += quintillion / Math.pow(n, 2); percentage += quintillion % (long)Math.pow(n, 2); } count += percentage / Math.pow(n, 2); percentage = 0; quintCount = 0; }*/ count = Long.parseLong(s) / (long) Math.pow(n, 2); System.out.println(count); count = 0; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
ee5ad0fd4be8c422aeffa689188f8843
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); short t; t=sc.nextShort(); while(t>0) { int n,count=0; long s; n=sc.nextInt(); s=sc.nextLong(); if(s<n*n) { System.out.println(count); } else { count=(int)((s/n)/n); System.out.println(count); } t--; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
6d99d18d5cf1e4957321b07b83d0ec10
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class theatre { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); while(n>0) { long n1=sc.nextLong(); long n2=sc.nextLong(); long n3=0; if(n1==0) { n3=0; } else { n3=n2/(n1*n1); } System.out.println(n3); n--; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
5992b1c4768f6875706495e08538ef8b
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class SquareCounting { public static void main(String[] args){ Scanner s = new Scanner(System.in); int t = Integer.parseInt(s.nextLine()); for(int i=0; i<t; i++){ long n = s.nextLong(); long ss = s.nextLong(); if(n == 0){ System.out.println("0"); } else { System.out.println(ss/(n*n)); } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
8527088836e07f35b92b8fe7b2ffa185
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner x = new Scanner(System.in); var y = x.nextLong(); for (int i = 0; i < y; i++) { var n = x.nextLong(); var s = x.nextLong(); System.out.println((s / (n * n))); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
1e521c33fa3644e4302cd5f4c2e911aa
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner x = new Scanner(System.in); long y = x.nextLong(); for (int i = 0; i < y; i++) { long n = x.nextLong(); long s = x.nextLong(); System.out.println((s / (n * n))); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
7401f60c7f5d420d8c6a7b407ff4e794
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Test { public static void main(String[] args) { int T; Scanner sc = new Scanner(System.in); T = sc.nextInt(); sc.nextLine(); for(int i = 0;i < T;i++) { long n = sc.nextLong(); long s = sc.nextLong(); sc.nextLine(); long square = n * n; // get the quotient without the decimal places long result = s / square; System.out.println(result); } sc.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
1332d7f7429e986d6e380fb28c9fe670
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
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){ long n,s; n=sc.nextLong(); s=sc.nextLong(); System.out.println(s/n/n); } sc.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
f17cc7429f5c5bb1451ae412b234e663
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
// Working program with FastReader import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Sol{ public static void main(String[] arg) { FastReader in = new FastReader(); int t = in.nextInt(); while (t -- > 0) { long n = in.nextLong(); long s = in.nextLong(); System.out.println(s/(n*n)); } } // fast io 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()); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
08c299721cd8da5885ac73b1a7005483
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class SquareCounting { public static void main(String[] args) { Scanner s1 = new Scanner(System.in); int m = s1.nextInt(); BigInteger[] s = new BigInteger[m]; BigInteger[] n = new BigInteger[m]; for (int i = 0; i < m; i++) { n[i] = s1.nextBigInteger(); s[i] = s1.nextBigInteger(); } for (int j = 0; j < m; j++) { System.out.println(s[j].divide((n[j]).pow(2))); } s1.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
06c7ba1cf1a3df665d081c12de460b02
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); for (int i = 0;i<num;i++){ long n = sc.nextLong(); long s = sc.nextLong(); long squared = n*n; if (s<squared){ System.out.println(0); } else if(s==squared){ System.out.println(1); } else{ long result = s/squared; System.out.println(result); } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
9ed71dbd4f74494189a873057c20735c
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner s = new Scanner(System.in); int t = s.nextInt(); // number of test cases while(t>0){ long n = s.nextLong(); long sum = s.nextLong(); long c = sum/(n*n); System.out.println(c); t = t-1; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
a3203e3e8e66a7612420d390c9303faf
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class class381 { public static void main(String arg[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { long n=sc.nextLong(); long s=sc.nextLong(); long sq=n*n; long c=s/sq; System.out.println(c); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
ec66b94d98600b84aaf71a215c04b19f
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); long n,s; while (t-- > 0) { n=sc.nextLong(); s=sc.nextLong(); if(n>s) System.out.println(0); else if(n==s) System.out.println(n==1?1:0); else System.out.println(s/(n*n)); } sc.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
df607d95f9dbd3d3c9631073ea008cce
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class square{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t --> 0){ BigInteger n = new BigInteger(in.next()); BigInteger s = new BigInteger(in.next()); BigInteger k = new BigInteger("0"); if(!n.equals(0)){ //(long) s/(n*n) k = s.divide(n.multiply(n)); } System.out.println(k); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
bd2fdba9bd7afadf8e41991afa00b298
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.*; public class c { public static void main(String[] args) { PrintWriter pw = new PrintWriter(System.out); FastReader sc = new FastReader(); int tc = sc.nextInt(); while (tc-- > 0) { long n = sc.nextLong(); long s = sc.nextLong(); long count = 0; if (s == 0) { pw.println(count); continue; } count = s / (n * n); pw.println(count); } pw.close(); } public static int solve(int n, long s) { int cnt = 0; int a = 1; loop: for (int i = 0; i <= n; i++) { if (i > n) { break loop; } if (s >= (n * n)) { s = s - (n * n); cnt++; continue loop; } if (a < n) { s = s - a; a++; } } return cnt; } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
94035152b43ad2f6bea54231c0d2dd08
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class onlysample { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t > 0) { long n=sc.nextLong(); long s=sc.nextLong(); n=n*n; long count=s/n; System.out.println(count); t--; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
aff5e0d5d8f61eebc2ca5a5ce990b779
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class Div_2_774_A { public static void main(String[] args){ Scanner sc = new Scanner(System.in); long t = sc.nextInt(); while(t -- > 0){ BigInteger n = sc.nextBigInteger(); BigInteger s = sc.nextBigInteger(); BigInteger square = n.multiply(n); System.out.println(s.divide(square)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
f54875c509a43ef9ca180708302c0465
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; import java.util.*; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); for(int i=0; i<t; i++){ long n = scn.nextLong(); long s = scn.nextLong(); long temp = n*n; if(s == 0){ System.out.println(s); } else{ s /= temp; System.out.println(s); } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
fee60ca08069681bb6eb49b632a5af9a
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for(int i = 0; i < t; i ++){ long n = scanner.nextLong(); long nSquared = n * n; long s = scanner.nextLong(); if(nSquared == 0 || s == 0) System.out.println(0); else System.out.println(s / nSquared); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
25f45818b6fb3c97e89f6e906beeb828
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class SquareCounting{ public static void main(String[] args){ Scanner sc= new Scanner(System.in); int t=sc.nextInt(); if(t>=1&&t<=20000){ while(t>0){ long s,n; n = sc.nextLong(); s = sc.nextLong(); if(n>=1&&n<=1000000&&s>=0&&s<=(long)Math.pow(10,18)){ long x= (n-1)*(n+1); long c=0; long y=s-x; if(s-x>0){ if(y%(n*n)==0) c= y/(n*n); else c=y/(n*n)+1; } System.out.println(c); } t--; } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
b50c7151cf41d1751be4674615cb3f24
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Problem{ public static void main(String args[]){ Scanner obj = new Scanner(System.in); int t = obj.nextInt(); while(t!=0){ Long n = obj.nextLong(); Long s = obj.nextLong(); Long val = n * n; Long count = s!=0?(Long)s/val:0; System.out.println(count); t--; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
e49c79a9605897a466e54e561828272a
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class squareCounting { public static void main(String [] args) { Scanner in = new Scanner(System.in); int cases = in.nextInt(); for (int i = 0; i < cases; i++) { long n = in.nextLong(); long s = in.nextLong(); long sqr = n*n; System.out.println(s/sqr); } in.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
1073131c6914ba5b4fb74962ab9fc9d9
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class squareCounting { public static void main(String [] args) { Scanner in = new Scanner(System.in); int cases = in.nextInt(); for (int i = 0; i < cases; i++) { long n = in.nextLong(); long s = in.nextLong(); solve(n, s); } in.close(); } public static void solve(long n, long s) { long sqr = n*n; System.out.println(s/sqr); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
7ee547faba15d68f96f6be52d69911f6
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; public class Template { static int mod = 1000000007; public static void main(String[] args){ FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int yo = sc.nextInt(); while (yo-- > 0) { long n = sc.nextLong(); long s = sc.nextLong(); long nsq = n * 1l * n; long a = s; long b = nsq; long ans = a/b; out.println(ans); } out.close(); } /* Source: hu_tao Random stuff to try when stuck: - use bruteforcer - check for n = 1, n = 2, so on -if it's 2C then it's dp -for combo/probability problems, expand the given form we're interested in -make everything the same then build an answer (constructive, make everything 0 then do something) -something appears in parts of 2 --> model as graph -assume a greedy then try to show why it works -find way to simplify into one variable if multiple exist -treat it like fmc (note any passing thoughts/algo that could be used so you can revisit them) -find lower and upper bounds on answer -figure out what ur trying to find and isolate it -see what observations you have and come up with more continuations -work backwards (in constructive, go from the goal to the start) -turn into prefix/suffix sum argument (often works if problem revolves around adjacent array elements) -instead of solving for answer, try solving for complement (ex, find n-(min) instead of max) -draw something -simulate a process -dont implement something unless if ur fairly confident its correct -after 3 bad submissions move on to next problem if applicable -do something instead of nothing and stay organized -write stuff down Random stuff to check when wa: -if code is way too long/cancer then reassess -switched N/M -int overflow -switched variables -wrong MOD -hardcoded edge case incorrectly Random stuff to check when tle: -continue instead of break -condition in for/while loop bad Random stuff to check when rte: -switched N/M -long to int/int overflow -division by 0 -edge case for empty list/data structure/N=1 */ public static class Pair { int x; int y; public Pair(int x, int y) { this.x = x; this.y = y; } } public static void sort(int[] arr) { 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 gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } static boolean[] sieve(int N) { boolean[] sieve = new boolean[N + 1]; for (int i = 2; i <= N; i++) sieve[i] = true; for (int i = 2; i <= N; i++) { if (sieve[i]) { for (int j = 2 * i; j <= N; j += i) { sieve[j] = false; } } } return sieve; } public static long power(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 void print(int[] arr, PrintWriter out) { //for debugging only for (int x : arr) out.print(x + " "); out.println(); } public static int log2(int a){ return (int)(Math.log(a)/Math.log(2)); } public static long ceil(long x, long y){ return (x + 0l + y - 1) / y; } static class FastScanner { 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[] readInts(int N) { int[] res = new int[N]; for (int i = 0; i < N; i++) { res[i] = (int) nextLong(); } return res; } public long[] readLongs(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[] readDoubles(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; } } } // For Input.txt and Output.txt // FileInputStream in = new FileInputStream("input.txt"); // FileOutputStream out = new FileOutputStream("output.txt"); // PrintWriter pw = new PrintWriter(out); // Scanner sc = new Scanner(in); }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
be85cce5a96407dba556eee7aaf3a8f9
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner var = new Scanner(System.in); int T = var.nextInt(); for(int i = 1; i <= T; i ++){ long n = var.nextLong(); long s = var.nextLong(); System.out.println(s/(long)(n*n)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
b9fd7567207f5f76d319a3654fe09c63
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++){ long n = sc.nextLong(); long s = sc.nextLong(); System.out.println(((s/(long)(Math.pow(n,2))))); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
6ddc006412be02998cf42858f55f884d
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw= new PrintWriter(System.out); StringTokenizer st= new StringTokenizer(br.readLine()); int n= Integer.parseInt(st.nextToken()); for (int i=0; i<n;i++){ long c; st= new StringTokenizer(br.readLine()); long a= Long.parseLong(st.nextToken()); long b=Long.parseLong(st.nextToken()); if (a == 0){ if (b==0){ pw.println(1); continue; }else{ pw.println(0); continue; } } if (a*a>b){ pw.println(0); continue; } c= b/(a*a); pw.println(c); } /* for (int i=0; i<n;i++){ System.out.println(input[i][0]+" "+ input[i][1]); } */ br.close(); pw.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
f1719f36d4e435457515e17b38ac43aa
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Main{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); int c = sc.nextInt(); for(int count = 1;count<=c;count++){ long val; long n = sc.nextLong(); long s = sc.nextLong(); long f = n*n; if(s!=0 && s>=f){ val = s/f; }else{ val = 0; } System.out.println(val); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
1e8e4ffd23015eac66a0e771e0562e56
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Codeforces { public static void main(String[] args) { try { Scanner sc = new Scanner(System.in); long t = sc.nextLong(); while (t-- > 0) { long n = sc.nextLong(); long s = sc.nextLong(); if(s==0) System.out.println(0); else { System.out.println(s/(n*n)); } } } catch (Exception e) { return; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
57f5c5612a6fdd0faff43d5fc060ce4b
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; public class A_Square_Counting { public static void main(String[] args) { OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); FastReader f = new FastReader(); int t = f.nextInt(); while(t-- > 0){ long n = f.nextLong(); long s = f.nextLong(); long res = (long)Math.floor(s/(n*n)); out.println(res); } out.close(); } public static void allDivisors(int n) { for(int i = 1; i*i <= n; i++) { if(n%i == 0) { System.out.println(i + " "); if(i != n/i) { System.out.println(n/i + " "); } } } } public static boolean isPrime(int n) { if(n < 1) return false; if(n == 2 || n == 3) return true; if(n % 2 == 0 || n % 3 == 0) return false; for(int i = 5; i*i <= n; i += 6) { if(n % i == 0 || n % (i+2) == 0) { return false; } } return true; } public static int Gcd(int a, int b) { int dividend = a > b ? a : b; int divisor = a < b ? a : b; while(divisor > 0) { int reminder = dividend % divisor; dividend = divisor; divisor = reminder; } return dividend; } public static int lcm1(int a, int b) { int lcm = Gcd(a, b); int hcf = (a * b) / lcm; return hcf; } 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()); } float nextFloat() { return Float.parseFloat(next()); } boolean nextBoolean() { return Boolean.parseBoolean(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } } /** Dec Char Dec Char Dec Char Dec Char --------- --------- --------- ---------- 0 NUL (null) 32 SPACE 64 @ 96 ` 1 SOH (start of heading) 33 ! 65 A 97 a 2 STX (start of text) 34 " 66 B 98 b 3 ETX (end of text) 35 # 67 C 99 c 4 EOT (end of transmission) 36 $ 68 D 100 d 5 ENQ (enquiry) 37 % 69 E 101 e 6 ACK (acknowledge) 38 & 70 F 102 f 7 BEL (bell) 39 ' 71 G 103 g 8 BS (backspace) 40 ( 72 H 104 h 9 TAB (horizontal tab) 41 ) 73 I 105 i 10 LF (NL line feed, new line) 42 * 74 J 106 j 11 VT (vertical tab) 43 + 75 K 107 k 12 FF (NP form feed, new page) 44 , 76 L 108 l 13 CR (carriage return) 45 - 77 M 109 m 14 SO (shift out) 46 . 78 N 110 n 15 SI (shift in) 47 / 79 O 111 o 16 DLE (data link escape) 48 0 80 P 112 p 17 DC1 (device control 1) 49 1 81 Q 113 q 18 DC2 (device control 2) 50 2 82 R 114 r 19 DC3 (device control 3) 51 3 83 S 115 s 20 DC4 (device control 4) 52 4 84 T 116 t 21 NAK (negative acknowledge) 53 5 85 U 117 u 22 SYN (synchronous idle) 54 6 86 V 118 v 23 ETB (end of trans. block) 55 7 87 W 119 w 24 CAN (cancel) 56 8 88 X 120 x 25 EM (end of medium) 57 9 89 Y 121 y 26 SUB (substitute) 58 : 90 Z 122 z 27 ESC (escape) 59 ; 91 [ 123 { 28 FS (file separator) 60 < 92 \ 124 | 29 GS (group separator) 61 = 93 ] 125 } 30 RS (record separator) 62 > 94 ^ 126 ~ 31 US (unit separator) 63 ? 95 _ 127 DEL */
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
b7aa78b3cb4ed24e364d06e268966b62
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); StringBuilder builder = new StringBuilder(); while (t-- > 0) { long n = scanner.nextInt(); long s = scanner.nextLong(); long nsq = n * n; long m = nsq - 1; long ans = (s - m) / nsq; if (s - m - nsq*ans > 0) ans++; builder.append(ans).append(System.lineSeparator()); } System.out.println(builder); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
f856b8c2e8bfde3f3ea5bb6c26663917
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class rational_number{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); long t=sc.nextLong(); for(int i=0;i<t;i++) { long n = sc.nextLong(); long s = sc.nextLong(); System.out.println(s/(n*n)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
b6aa4cad7c544d5ea70832ea0e2da373
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class squareCounting { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0) { long n = s.nextInt(); long s1 = s.nextLong(); long sq = n*n; System.out.println(s1/sq); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
7d31fa9d69865fd14cc8115f065e71ca
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class codeforces_4March { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i =0;i<t;i++){ long n = sc.nextLong(); long s = sc.nextLong(); System.out.println(s/(long) Math.pow(n,2)); // if(s == 0 || n==0){ // System.out.println(0); // continue; // } // else if(n==1){ // System.out.println(1); // continue; // } // int c =0; // int m = 0; // while(m<s && s>=Math.pow(n,2)){ // m+=Math.pow(n,2); // c+=1; // } // // int k = n; // while(Math.pow(k,2)<=s){ // n =(int) Math.pow(k,2); // s = s-n; // c+=1; // } // System.out.println(c); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
c698e95a892399e46b5c72c9791b67b3
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Square_Counting { public static void main(String Args[]) { Scanner obj = new Scanner(System.in); int t = obj.nextInt(); while (t > 0) { t--; int n = obj.nextInt(); long s = obj.nextLong(); double p = Math.pow(n,2); if (p > s) { System.out.println("0"); } else { long d = s / (long)p; System.out.println(d); } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
105b6ddc19ef2ca40833e567ecea648c
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.math.BigInteger; import java.util.*; public class ProgramJava { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while (T>0){ T--; long n = sc.nextLong(); long s = sc.nextLong(); long nsq = n*n; long c = 0; c = s/nsq; System.out.println(c); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
4abdc2992cf1aca193390f74e4f78a17
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.*; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // if (System.getProperty("ONLINE_JUDGE") == null) { // try { // System.setOut(new PrintStream( // new FileOutputStream("output.txt"))); // sc = new Scanner(new File("input.txt")); // } // catch (Exception e) { // } // } int t =sc.nextInt(); while (t-->0) { long n= sc.nextLong(); long s= sc.nextLong(); if(s==0 || n==0) System.out.println(0); else{ System.out.println((long)(s/(n*n))); } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
b4d2e3e4531911f08ec5b2c3d7976499
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; /* 4 7 0 1 1 2 12 3 12 */ public class Creep { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t>0){ long n = scan.nextLong(); long s = scan.nextLong(); long p = s / (n * n); System.out.println(p); t--; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
8609ad270800b22385a8b5b6b8d5465d
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class thisDaMain { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t=sc.nextInt(); while (t>0){ long n = sc.nextLong(); long s = sc.nextLong(); if(s<n*n || s==0) System.out.println("0"); else System.out.println(s/(n*n)); t--; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
d6813c6e8059854d3a42852fda787a9b
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; import static java.lang.System.*; // for error stream (static) was necessary. // @author : sam45jh public class Main{ /* declare some global variables */ static FastReader scn; static FastWriter out; static int imax = Integer.MAX_VALUE; static int imin = Integer.MIN_VALUE; 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.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 { BufferedWriter bw; List<String> list = new ArrayList<>(); Set<String> set = new HashSet<>(); FastWriter() { bw = new BufferedWriter(new OutputStreamWriter(System.out)); } <T> void print(T obj) throws IOException { bw.write(obj.toString()); bw.flush(); } void println() throws IOException { print("\n"); } <T> void println(T obj) throws IOException { print(obj.toString() + "\n"); } void print(int[] arr) throws IOException { for (int x : arr) { print(x + " "); } println(); } void print(long[] arr) throws IOException { for (long x : arr) { print(x + " "); } println(); } void print(boolean[] arr) throws IOException{ for(boolean x:arr) print(x+" "); } void print(double[] arr) throws IOException { for (double x : arr) { print(x + " "); } println(); } void print(float[] nums) throws IOException{ for(float x: nums){ print(x+" "); } println(); } void printCharN(char c, int n) throws IOException { for (int i = 0; i < n; i++) { print(c); } } } /* print functions for primitives and String*/ private static void print(int s) throws IOException { out.println(s); } private static void print(long s) throws IOException { out.println(s); } private static void print(boolean s) throws IOException{ out.println(s); } private static void print(double s) throws IOException { out.println(s); } private static void print(String s) throws IOException{ out.println(s); } private static void print(float s) throws IOException{ out.println(s); } private static void print(char ch) throws IOException{ out.println(ch); } /* Setting debug functions for primitives and String*/ private static void debug(int s) throws IOException{ err.println(s); } private static void debug(long s) throws IOException{ err.println(s); } private static void debug(boolean s) throws IOException{ err.println(s); } private static void debug(float s) throws IOException{ err.println(s); } private static void debug(double s) throws IOException{ err.println(s); } private static void debug(String s) throws IOException{ err.println(s); } private static void debug(char s) throws IOException{ err.println(s); } /* Disclaimer */ // note that if you want to use a function than use IOException; // public static void call() throws IOException{ // print(10+"Abhishek Jha"); // } /* Main function */ private static void debug(ArrayList<Integer> nums) throws IOException{ err.println(nums); } public static boolean bs(int[] nums, int key){ int start = 0; int end = nums.length-1; int mid = (start+end)/2; while(start<=end){ int val = nums[mid]; if(val == key)return true; else if(val < key) start = mid + 1; else end = mid - 1; mid = (start+end)/2; } return false; } public static void main(String[] hi) throws IOException{ initializeIO(); scn = new FastReader(); out = new FastWriter(); // String[] s = scn.nextLine().trim().split(" "); long t = scn.nextLong(); while(t--!=0){ long n = scn.nextLong(); long s = scn.nextLong(); long val = n*n; print(s/val); } } /* sorting an array in nlogn time */ public static void sort(int[] nums){ // the reason I dont use Arrays.sort(nums) is that it uses quick sort and // that has a TC of n2 in worst case. However, Collections sort uses merge sort // which is always nlogn even in worst case. ArrayList<Integer> vals = new ArrayList<>(); for(int i=0;i<nums.length;i++){ vals.add(nums[i]); } Collections.sort(vals); for(int i=0;i<vals.size();i++){ nums[i]=vals.get(i); } } private static void initializeIO(){ try { System.setIn(new FileInputStream("input.txt")); System.setOut(new PrintStream(new FileOutputStream("output.txt"))); System.setErr(new PrintStream(new FileOutputStream("error.txt"))); } catch (Exception e) { System.err.println(e.getMessage()); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
1df9c9060d1d782afb51241fcc5f1475
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class P1646A { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int count = scanner.nextInt(); for (int i = 0; i < count; i++) { solve3(scanner); } } public static void solve(Scanner sc) throws Exception { long n = sc.nextLong(); long s = sc.nextLong(); long sprime = s; long nprime = n; long c = 0; while (sprime >= n*n && nprime +1 > 0) { sprime = sprime - n*n; nprime--; c++; } // System.out.println(""); System.out.println(c); } public static void solve1(Scanner sc) throws Exception { long n = sc.nextLong(); long s = sc.nextLong(); double chunk = (s - (n*n+n)); chunk = chunk/(n*n-n); double chunk2 = s/(n*n); long res; if (chunk2 >= chunk) { res = (long) chunk2; } else { res = 0; } // System.out.println(""); System.out.println(res); } public static void solve3(Scanner sc) throws Exception { long n = sc.nextLong(); long s = sc.nextLong(); System.out.println(s/(n*n)); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
8a34edf68adc225526cdcbc7e86ddffe
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main { static Kattio io; static long mod = 998244353, inv2 = 499122177; static { io = new Kattio(); } public static void main(String[] args) { int t = io.nextInt(); for (int i = 0; i < t; i++) { solve(); } io.close(); } private static void solve() { long n = io.nextLong(), s = io .nextLong(); io.println(s/(n*n)); } static class pair implements Comparable<pair> { private final int x; private final int y; int id; public pair(final int x, final int y) { this.x = x; this.y = y; } @Override public String toString() { return "pair{" + "x=" + x + ", y=" + y + '}'; } @Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof pair)) { return false; } final pair pair = (pair) o; if (x != pair.x) { return false; } if (y != pair.y) { return false; } return true; } @Override public int hashCode() { int result = x; result = (int) (31 * result + y); return result; } @Override public int compareTo(pair pair) { return Integer.compare(pair.x, this.x); } } static class Kattio extends PrintWriter { private BufferedReader r; private StringTokenizer st; // standard input public Kattio() { this(System.in, System.out); } public Kattio(InputStream i, OutputStream o) { super(o); r = new BufferedReader(new InputStreamReader(i)); } // USACO-style file input public Kattio(String problemName) throws IOException { super(new FileWriter(problemName + ".out")); r = new BufferedReader(new FileReader(problemName + ".in")); } // returns null if no more input public String next() { try { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(r.readLine()); return st.nextToken(); } catch (Exception e) {} return null; } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public long nextLong() { return Long.parseLong(next()); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
6d943d9c588eb257e0e04a0acdf9b4ff
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; public class Main { static FastReader in=new FastReader(); static final Random random=new Random(); static long mod=1000000007L; static HashMap<String,Integer>map=new HashMap<>(); public static void main(String args[]) throws IOException { int t=in.nextInt(); while(t-->0){ long arr[]=in.readlongarray(2); long n=arr[0]; long s=arr[1]; print(s/(n*n)); } } static int max(int a, int b) { if(a<b) return b; return a; } static void ruffleSort(int[] a) { int n=a.length; for (int i=0; i<n; i++) { int oi=random.nextInt(n), temp=a[oi]; a[oi]=a[i]; a[i]=temp; } Arrays.sort(a); } static < E > void print(E res) { System.out.println(res); } static int gcd(int a,int b) { if(b==0) { return a; } return gcd(b,a%b); } static int lcm(int a, int b) { return (a / gcd(a, b)) * b; } static int abs(int a) { if(a<0) return -1*a; return a; } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } int [] readintarray(int n) { int res [] = new int [n]; for(int i = 0; i<n; i++)res[i] = nextInt(); return res; } long [] readlongarray(int n) { long res [] = new long [n]; for(int i = 0; i<n; i++)res[i] = nextLong(); return res; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
741099359bbea1521562457d852cc4b2
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class SquareCounting { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while (t-- > 0) { long a = s.nextLong(); long b = s.nextLong(); if (a * a > b) { System.out.println(0); } else { System.out.println(b / (a * a)); } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
f824fcfa3eec31f53725263ee3911c28
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
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){ long n =sc.nextLong(); long s =sc.nextLong(); long count=0; System.out.println(s/(n*n)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
723a64ae6d587e45a70fca9678077fde
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.lang.*; public class Main{ public static void main(String args[]){ Scanner inp=new Scanner(System.in); long t=inp.nextLong(); for(long i=0;i<t;i++){ long count=0,coun=0; long n=inp.nextLong(); long s=inp.nextLong(); long sample=n*n; System.out.println(s/sample); /* for(long j=1;j<=n+1;j++){ if(sample>s){ break; } else if(sample==s){ count++; //System.out.println(count); break; } else if(sample<s){ count++; sample=sample+(n*n); //System.out.println(" "+count+" "+sample); } }*/ // System.out.println(count); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
81286f02615d8dac21c3f6c7cce4561e
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; import java.util.Arrays; public class solution { static FastReader in=new FastReader(); static final Random random=new Random(); static long mod=1000000007L; static HashMap<String,Integer>map=new HashMap<>(); public static void main(String args[]) throws IOException { int t=in.nextInt(); while(t-->0){ long n=in.nextLong(); long s=in.nextLong(); System.out.println(s/(n*n)); } } static class Node{ int diff,a,b; Node(int a,int b){ this.a=a; this.b=b; diff=a-b; } } static void sort(int[] arr,int i,int j){ for(int l=i;l<j;l++){ for(int k=l+1;k<j;k++){ if(arr[l]>arr[k]){ swap(arr,l,k); } } } } static boolean isPrime(int n){ for(int i=2;i*i<=n;i++) if(n%i==0) return false; return true; } static char get(int a){ return (char)(a+'a'); } static int countNeighbours(int[][] arr,int i,int j){ int c=0,n=arr.length,m=arr[0].length; if(i-1>=0) c++; if(i+1<n) c++; if(j-1>=0) c++; if(j+1<m ) c++; return c; } static String flipBit(String s,int i){ StringBuilder sb=new StringBuilder(s); if(s.charAt(i)=='0') sb.setCharAt(i,'1'); else sb.setCharAt(i,'0'); return sb.toString(); } static int pow10(int n){ int pow=1; for(int i=0;i<n;i++) pow*=10; return pow; } static boolean atmostKBits(int a,int b,int m){ int k=0; for(int i=0;i<32;i++){ if(isBitSet(a,i) && isBitSet(b,i) || !isBitSet(a,i) && !isBitSet(b,i)) continue; k++; } return k<=m; } static boolean isBitSet(int n,int i){ return ((n>>i)&1)==1; } static boolean valid(int n,int m,int i,int j){ return (i>=0 && i<n) && (j>=0 && j<m); } static void swap(int[] p,int i,int j){ int temp=p[i]; p[i]=p[j]; p[j]=temp; } static boolean validate(String a,String b){ String c=""; for(int i=0;i<a.length();i++){ if(a.charAt(i)<b.charAt(i)) c+=a.charAt(i)+""; else c+=b.charAt(i)+""; } return c.equals(b); } static void solve(int n,int a,int b){ if(a>=b+2){ System.out.println(-1); return; } int half=n/2; List<Integer> left = new ArrayList<>(); List<Integer> right = new ArrayList<>(); List<Integer> rests = new ArrayList<>(); for (int i = 1; i <= n; ++i) { if (i == a || i > b) { left.add(i); } else if (i == b || i < a) { right.add(i); } else { rests.add(i); } } if (left.size() > half || right.size() > half) { System.out.println(-1); return; } int restIndex = 0; while (left.size() != half && restIndex<rests.size()) { left.add(rests.get(restIndex)); ++restIndex; } while (right.size() != half && restIndex<rests.size()) { right.add(rests.get(restIndex)); ++restIndex; } for(int i:left) System.out.print(i+" "); for(int i:right) System.out.print(i+" "); System.out.println(); } static void reverseArr(int[] arr,int l,int r){ while(l<r){ int temp=arr[l]; arr[l++]=arr[r]; arr[r--]=temp; } } // static int minArray(List<Integer> arr){ // int min=Integer.MAX_VALUE; // for(int i:arr) min=min(min,i); // return min; // } static int findmax(List<Integer> arr){ int max=0; for(int i:arr) max=max(max,i); return max; } static int countDistinctChars(String s){ Set<Character> set=new HashSet<>(); for(char c:s.toCharArray()) set.add(c); return set.size(); } static boolean check(int[] arr,int i){ if(i==0) return (arr[i]>arr[i+1]); else if(i==arr.length-1) return (arr[i]>arr[i-1]); return (arr[i]>arr[i-1] || arr[i]>arr[i+1]); } static boolean containsSubsequence(String s,String a){ int i=0,j=0; while(i<a.length() && j<s.length()){ if(s.charAt(j)==a.charAt(i)) i++; j++; } return i>=a.length(); } static boolean isPalindrome(String a){ int n=a.length(); for(int i=0;i<a.length();i++){ if(a.charAt(i)!=a.charAt(n-i-1)) return false; } return true; } static int lengthOfLIS(int[] nums) { int n=nums.length; int[] lisi = new int[n]; for(int i=0;i<n;i++) lisi[i]=1; for(int i=1;i<n;i++){ for(int j=0;j<i;j++){ if(nums[j]<=nums[i]){ lisi[i]=lisi[j]+1; } } } return lisi[n-1]; } // static int lengthOfLIS(int[] nums) // { // int[] tails = new int[nums.length]; // int size = 0; // for (int x : nums) { // int i = 0, j = size; // while (i != j) { // int m = (i + j) / 2; // if (tails[m] <= x) // i = m + 1; // else // j = m; // } // tails[i] = x; // if (i == size) ++size; // } // return size; // } static int max(int a, int b) { if(a<b) return b; return a; } static int min(int a,int b){ if(a > b) return b; return a; } static void ruffleSort(int[] a) { int n=a.length; for (int i=0; i<n; i++) { int oi=random.nextInt(n), temp=a[oi]; a[oi]=a[i]; a[i]=temp; } Arrays.sort(a); } static < E > void print(E res) { System.out.println(res); } static int gcd(int a,int b) { if(b==0) { return a; } return gcd(b,a%b); } static int lcm(int a, int b) { return (a / gcd(a, b)) * b; } static int abs(int a) { if(a<0) return -1*a; return a; } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } int [] readintarray(int n) { int res [] = new int [n]; for(int i = 0; i<n; i++)res[i] = nextInt(); return res; } long [] readlongarray(int n) { long res [] = new long [n]; for(int i = 0; i<n; i++)res[i] = nextLong(); return res; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
2fd7fa58b00e412b0c7680eb0a7e0450
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class EG { static int lsb(int n) { for(int i=31;i>=0;i--) { int num=1<<i; if((num&n)!=0)return i; } return 0; } public static void main(String[] args){ FastScanner fs=new FastScanner(); int t=fs.nextInt(); while(t-->0) { long n=fs.nextLong(); long sum=fs.nextLong(); if(sum==0)System.out.println(0); else System.out.println(sum/(n*n)); } } static int gcd(int a,int b) { return a==0? b:gcd(b%a,a); } static void dfs(int u,int graph[],boolean visit[]) { if(visit[u]) { System.out.print(u+" "); return; } visit[u]=true; dfs(graph[u],graph,visit); visit[u]=false; } // static void sieveOfEratosthenes() // { // // int n=prime.length; // for (int i = 0; i <n ; i++) // prime[i] = true; // // for (int p = 2; p * p <n; p++) // { // // If prime[p] is not changed, then it is a // // prime // if (prime[p] == true) // { // // Update all multiples of p // for (int i = p * p; i < n; i += p) // prime[i] = false; // // } // } // } } 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()); } double nextDouble() { return Double.parseDouble(next()); } String nextChar() { return next(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
96ce7dbf15e14d10f5091745d9934300
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class go { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int x= sc.nextInt(); while(x-- !=0){ long n= sc.nextLong(); long s= sc.nextLong(); System.out.println(s/(n*n)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
e0f607714a1854953bb8ccffcdc4107e
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class MyClass { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { long n = sc.nextLong(); long s = sc.nextLong(); long r = s/(n*n); System.out.println(r); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
4984173fa6ccf64b684c9286662afbaf
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class MyClass { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { long n = sc.nextLong(); long s = sc.nextLong(); long r = s/(n*n); System.out.println(r); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
ac1f457aba504f82ad68d643e995d1a1
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.StringTokenizer; public class cf { 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) { FastReader con = new FastReader(); int t = con.nextInt(); while (t-- != 0) { long n = con.nextInt(); long s = con.nextLong(); long n2 = n * n; long count = 0; if (n2 <= s) count += (s / n2); System.out.println(count); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
7128f60b71241371f2aeb4937f2cfa93
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-- > 0) { System.out.println(solve(in)); } } public static long solve(Scanner in) { long n = in.nextLong(); long s = in.nextLong(); if(n == 0) return 0; long target = n * n; n++; long res = s / target; if(n == res) { if(s % target != 0) { return n - 1; } } else if(n < res) { return n - 1; } return res; } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
45ecaa4078244c60ba04c24cadc78dec
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; /** * * @author xpeng */ import java.util.*; import java.io.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.Arrays; import java.util.Comparator; public class USACO { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static StringTokenizer st; static int mod=(int)10e9+7; public static boolean isPrime(long n){ int i;long m = 0, flag = 0; m = n / 2; for (int j = 2; j <=m; j++) { if (n%j==0) { return false; } } return true; } public static void main(String[] args) throws IOException { int t = readInt(); for (int i = 0; i < t; i++) { long n = readLong(),s=readLong(); System.out.println((long)Math.floor(s/(long)Math.pow(n,2))); } } static void union(int from,int to,long[] size,int[] par){ if (size[to]>size[from]) { size[to]+=size[from]; par[from]=to; }else{ size[from]+=size[to]; par[to]=from; } } static int find(int[] par,int node){ if (par[node]!=node) { par[node]=find(par,par[node]); } return par[node]; } static class edge implements Comparable<edge>{ int from,to; long cost; edge(int from,int to,long cost){ this.from=from;this.to=to;this.cost=cost; } @Override public int compareTo(edge e) { return Long.compare(this.cost, e.cost); } } static class pair implements Comparable<pair>{ int y,x,rank; pair(int x,int y,int r){ this.y=y;this.x=x;this.rank=r; } @Override public int compareTo(pair p1) { if (this.x==p1.x) { return Integer.compare(this.y, p1.y); } return Integer.compare(this.x, p1.x); } } static String next() throws IOException { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(br.readLine().trim()); } return st.nextToken(); } static long readLong() throws IOException { return Long.parseLong(next()); } static int readInt() throws IOException { return Integer.parseInt(next()); } static double readDouble() throws IOException { return Double.parseDouble(next()); } static String readLine() throws IOException { return br.readLine().trim(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
c6b880acd4e893021b2b721f995c7cb2
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.PrintWriter; public class A { static final FastReader sc = new FastReader(); static final PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { int t = sc.nextInt(); while (t-- > 0) { long n = sc.nextLong(); long s = sc.nextLong(); if (s < n * n) { out.println(0); } else { out.println((long) s / (n * n)); } } out.close(); } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
35526f87587b094972b74ee1d9048f20
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
// 4 // 7 0 // 0 // 1 1 // 1 // 2 12 // 3 // 3 12 // 1 import java.util.*; public class SquareCounting { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long n = scan.nextLong(); long[][] arr = new long[(int)n][2]; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { arr[i][j] = scan.nextLong(); } } for (int i = 0; i < arr.length; i++) { for (int j = 1; j < arr[i].length; j++) { if (arr[i][0] * arr[i][0] <= arr[i][j]) { System.out.println((long)(arr[i][j] / ((arr[i][0]) * arr[i][0]))); } else { System.out.println("0"); } } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
9ff9e8e347103e07b6db75c05a0d8207
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner scan = new Scanner(System.in); //ArrayList<Character> letters = new ArrayList<Character>(); // int[] a = {6,7,13,14,20,21,27,28}; int x = scan.nextInt(); for(int i = 0; i<x; i++) { long n = scan.nextLong(); long s = scan.nextLong(); if(n==0) { System.out.println(1); } else { System.out.println(s/(n*n)); } } scan.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
b06ab7bc946b808e4a3bba2e00ddcc0b
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class P3 { public static void main(String[] args) { Scanner in= new Scanner(System.in); int t=in.nextInt(); long []n=new long[t]; long []s=new long[t]; for(int i=0;i<t;i++) { n[i]=in.nextLong(); s[i]=in.nextLong(); } for(int i=0;i<t;i++) { if(s[i]<(n[i]*n[i]-1)) System.out.println(0); else { long k=(s[i]-n[i]*n[i]+1)/(n[i]*n[i]-n[i]+1); long l=(s[i]-n[i]*n[i]+1)%(n[i]*n[i]-n[i]+1); if(l==0) { System.out.println(k); } else { System.out.println(k+1); } } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
436dd758a347ac00212989cf6e91c976
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class P2 { public static void main(String[] args) { Scanner in= new Scanner(System.in); int t=in.nextInt(); long []n=new long[t]; long []s=new long[t]; for(int i=0;i<t;i++) { n[i]=in.nextLong(); s[i]=in.nextLong(); } for(int i=0;i<t;i++) { long k=n[i]*n[i]-1; if(s[i]<k) { System.out.println(0); } else { long l=(s[i]-n[i]*n[i]+1)/(n[i]*n[i]-n[i]+1); long m=(s[i]-n[i]*n[i]+1)%(n[i]*n[i]-n[i]+1); if(m==0) System.out.println(l); else System.out.println(l+1); } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
56aa1dde053b3ac0c85ed9b6b419fc26
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class plusOne { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { long n=sc.nextLong(); long s=sc.nextLong(); long ans= s/(n*n); System.out.println(ans); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
63029973eafee731ca58eb7b24602259
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; import java.security.KeyStore.Entry; public class Main{ static final Random random=new Random(); static long mod=1000000007L; static HashMap<String,Integer>map=new HashMap<>(); 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; } int[] readIntArray(int n){ int[] res=new int[n]; for(int i=0;i<n;i++)res[i]=nextInt(); return res; } } 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(); } } static int ans=0; public static void main(String[] args) { try { FastReader in=new FastReader(); FastWriter out = new FastWriter(); int testCases=in.nextInt(); //int testCases=1; while(testCases-- > 0){ solve(in); } out.close(); } catch (Exception e) { System.out.println(e); return; } } public static void solve( FastReader in){ long n=in.nextInt(); long s=in.nextLong(); //String t=in.next(); //long y=in.nextInt(); //long n=in.nextLong(); //int m=in.nextInt(); //int k=in.nextInt(); //String s=in.next(); //long k=in.nextLong(); StringBuilder res=new StringBuilder(); long ans=(s*1L)/(n*n*1L); res.append(""+ans); System.out.println(res.toString()); } static void dfs(int i,HashMap<Integer,ArrayList<Integer>> hp,Set<Integer> a){ a.add(i); for(int e:hp.get(i)){ if(!a.contains(e)){ dfs(e,hp,a); } } } static void bfs(ArrayList<ArrayList<Pair>> hp,int u,int v,Set<Integer> arr){ Queue<Integer> q=new LinkedList<>(); int ans=0; for(int col:arr){ HashSet<Integer> vi=new HashSet<>(); q.add(u); while(!q.isEmpty()){ int p=q.poll(); if(p==v){ ans++; vi.clear(); q.clear(); //debug(""+ans); break; } if(vi.contains(p))continue; vi.add(p); for(Pair pai:hp.get(p)){ if(!vi.contains(pai.v) && pai.c==col){ q.add(pai.v); } } } } debug(""+ans); } static int ch(Map<String,String> hp,int n,String r){ for(int i=0;i<n-1;i++){ String x=r.substring(0,2); if(!hp.containsKey(x))return 0; r=hp.get(x)+r.substring(2); } if(r.equals("a"))return 1; return 0; } static int gcd(int a,int b){ if(b==0){ return a; } return gcd(b,a%b); } static void sort(int[] arr) { 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); } static void reversesort(int[] arr) { ArrayList<Integer> ls = new ArrayList<Integer>(); for(int x: arr) ls.add(x); Collections.sort(ls); Collections.reverse(ls); for(int i=0; i < arr.length; i++) arr[i] = ls.get(i); } static int lcm(int a, int b) { return (a / gcd(a, b)) * b; } static void debug(String x){ System.out.println(x); } static < E > void print(E res) { System.out.println(res); } static String rString(String s){ StringBuilder sb=new StringBuilder(); sb.append(s); return sb.reverse().toString(); } static class Pair{ int v; int c; Pair(int v,int c){ this.v=v; this.c=c; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
5d0322565254edf83a30d02e907bed9a
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; //import java.lang.*; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++) { long n = sc.nextLong(); long s = sc.nextLong(); long nsquared = n * n; long result = 0; result = s/nsquared; System.out.println(result); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
d90986721d91b2bc2521dda8ff94f93d
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class maiin { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i=0;i<t;i++){ long n = sc.nextLong(); long s = sc.nextLong(); System.out.println(s/(n*n)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
64e0440616bed772c20e2350a0a329cc
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Square_Counting { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { long n = sc.nextLong(); long s = sc.nextLong(); long sqr = n*n; long count = s/sqr; System.out.println(count); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
aa3889d599d3a93ea375e55141afb91e
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class codeforces_4_march_A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for ( int i = 0 ; i<t; i++) { long n = sc.nextInt(); long s = sc.nextLong(); System.out.println((s/(n*n))); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
903c97a28a6fe005c90d8266eca958bd
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class counting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int numCases = scanner.nextInt(); for (int i = 0; i < numCases; i++) { int n = scanner.nextInt(); long s = scanner.nextLong(); long max = (long)n*n; int ans = max == 0 ? 0 : (int)(s / max); System.out.println(ans); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
84c40422cf34328036dcdf67c01d3ca8
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; public class Main { static StringBuilder sb; static dsu dsu; static long fact[]; static int mod = (int) (1e9 + 7); static void solve() { long n=i(); long s=l(); long ans=0; long lo=0; long hi=n+1; while(lo<=hi){ long mid=(lo+hi)/2; long temps=s-(long)(n*n*mid); long maxs=(n+1-mid)*(n-1); if(temps<0) { hi=mid-1; } else if(temps>maxs){ lo=mid+1; } else{ ans=mid; break; } } sb.append(ans+"\n"); } public static void main(String[] args) { sb = new StringBuilder(); int test = i(); while (test-- > 0) { solve(); } System.out.println(sb); } /* * fact=new long[(int)1e6+10]; fact[0]=fact[1]=1; for(int i=2;i<fact.length;i++) * { fact[i]=((long)(i%mod)1L(long)(fact[i-1]%mod))%mod; } */ //**************NCR%P****************** static long ncr(int n, int r) { if (r > n) return (long) 0; long res = fact[n] % mod; // System.out.println(res); res = ((long) (res % mod) * (long) (p(fact[r], mod - 2) % mod)) % mod; res = ((long) (res % mod) * (long) (p(fact[n - r], mod - 2) % mod)) % mod; // System.out.println(res); return res; } static long p(long x, long y)// POWER FXN // { if (y == 0) return 1; long res = 1; while (y > 0) { if (y % 2 == 1) { res = (res * x) % mod; y--; } x = (x * x) % mod; y = y / 2; } return res; } //**************END****************** // *************Disjoint set // union*********// static class dsu { int parent[]; dsu(int n) { parent = new int[n]; for (int i = 0; i < n; i++) parent[i] = -1; } int find(int a) { if (parent[a] < 0) return a; else { int x = find(parent[a]); parent[a] = x; return x; } } void merge(int a, int b) { a = find(a); b = find(b); if (a == b) return; parent[b] = a; } } //**************PRIME FACTORIZE **********************************// static TreeMap<Integer, Integer> prime(long n) { TreeMap<Integer, Integer> h = new TreeMap<>(); long num = n; for (int i = 2; i <= Math.sqrt(num); i++) { if (n % i == 0) { int nt = 0; while (n % i == 0) { n = n / i; nt++; } h.put(i, nt); } } if (n != 1) h.put((int) n, 1); return h; } //****CLASS PAIR ************************************************ static class Pair implements Comparable<Pair> { int x; long y; Pair(int x, long y) { this.x = x; this.y = y; } public int compareTo(Pair o) { return (int) (this.y - o.y); } } //****CLASS PAIR ************************************************** static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public int Int() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public String String() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public String next() { return String(); } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object... objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) writer.print(' '); writer.print(objects[i]); } } public void printLine(Object... objects) { print(objects); writer.println(); } public void close() { writer.close(); } public void flush() { writer.flush(); } } static InputReader in = new InputReader(System.in); static OutputWriter out = new OutputWriter(System.out); public static long[] sort(long[] a2) { int n = a2.length; ArrayList<Long> l = new ArrayList<>(); for (long i : a2) l.add(i); Collections.sort(l); for (int i = 0; i < l.size(); i++) a2[i] = l.get(i); return a2; } public static char[] sort(char[] a2) { int n = a2.length; ArrayList<Character> l = new ArrayList<>(); for (char i : a2) l.add(i); Collections.sort(l); for (int i = 0; i < l.size(); i++) a2[i] = l.get(i); return a2; } public static long pow(long x, long y) { long res = 1; while (y > 0) { if (y % 2 != 0) { res = (res * x);// % modulus; y--; } x = (x * x);// % modulus; y = y / 2; } return res; } //GCD___+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public static long gcd(long x, long y) { if (x == 0) return y; else return gcd(y % x, x); } // ******LOWEST COMMON MULTIPLE // ********************************************* public static long lcm(long x, long y) { return (x * (y / gcd(x, y))); } //INPUT PATTERN******************************************************** public static int i() { return in.Int(); } public static long l() { String s = in.String(); return Long.parseLong(s); } public static String s() { return in.String(); } public static int[] readArrayi(int n) { int A[] = new int[n]; for (int i = 0; i < n; i++) { A[i] = i(); } return A; } public static long[] readArray(long n) { long A[] = new long[(int) n]; for (int i = 0; i < n; i++) { A[i] = l(); } return A; } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
bfda7b092d2582a2d1b4a8a0393662d7
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A_Square_Counting { static void solve(long n, long sum) { if (sum == 0) { System.out.println(0); } else { long ans = sum / (n * n); System.out.println(ans); } } public static void main(String[] args) { try { FastReader s = new FastReader(); int t = s.nextInt(); while (t-- > 0) { long n = s.nextLong(); long sum = s.nextLong(); solve(n, sum); } /* * for(int i=0;i<t;i++) * { * System.out.println(arr[i]); * } */ } catch (Exception e) { return; } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
11a22f2103076330847df1f7ce8189f3
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class Main { static Scanner s = new Scanner(System.in); public static void main(String[] args) { int test_cases = s.nextInt(); for (int i = 0; i < test_cases; i++) { test_output(); } } static void test_output() { BigInteger n = new BigInteger(s.next()); BigInteger x = new BigInteger(s.next()); System.out.println(x.divide(n.multiply(n))); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
7a0fc1a5cb6fd5d473b53fc8c3d2798f
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here FastReader s = new FastReader(); int t = s.nextInt(); while(t-- != 0){ // if(n = 0){ // System.out.println(0); // continue; // } long n = s.nextLong(); long sum = s.nextLong(); System.out.println(sum/(n*n)); } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
da7c33f04703c058d3d11a6d527823a8
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // write your code here Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-->0){ long x = sc.nextLong(); long y = sc.nextLong(); System.out.println(y/(x*x)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
432938953562a31d56d2317e32b95765
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; public class Solution{ //class CodeChef{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = null; public static void main(String[] args)throws IOException { int testcase = Integer.parseInt(br.readLine()); while(testcase-->0){ st = new StringTokenizer(br.readLine()); Long n = Long.parseLong(st.nextToken()); Long s = Long.parseLong(st.nextToken()); long ans = s/(n*n); System.out.println(ans); } } } /* */
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
211b9b571d2035e0a795969d3cd421d3
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; public class Rextester { public static void main(String args[]) { Scanner sc =new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { long n=sc.nextLong(); long s=sc.nextLong(); System.out.println(s/(n*n)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
82c95ec97aa3d2327f1c65aa09b216c7
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import javax.print.DocFlavor; import java.net.CookieHandler; import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); for(int t = in.nextInt();t>0;t--) { long n = in.nextLong(); long s = in.nextLong(); System.out.println( s/(n*n)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
adec693fb02100d12d11e1ea1c6a62f4
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; import javax.lang.model.util.ElementScanner6; import java.lang.*; import java.util.*; public class codeforces { public static void main(String[] args) { Scanner ob = new Scanner(System.in); int t =ob.nextInt(); while (t-->0) { int n = ob.nextInt(); long s = ob.nextLong(); long ans = 0; ans = (s)/(long)Math.pow(n, 2); System.out.println(ans); } ob.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
7beceb4bb80c0c32a38c00c89dbf2ad3
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; public class cf1646A { public static void main(String[] args) { FastReader in = new FastReader(); int t = in.nextInt(); for (int i = 0; i < t; i++) { int n = in.nextInt(); long s = in.nextLong(); if ((long) n * n > s){ System.out.println(0); continue; } System.out.println(s / ((long) n * n)); } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
ae4effbcbdcc2963b5e91824162191c9
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int x=sc.nextInt(); outer: while(x-->0) { long n=sc.nextLong(); long k=sc.nextLong(); System.out.println((k/n)/n); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
e77a22f74088cdb9853e424e353ee299
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class A { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } // python interactive_runner.py python3 testing_tool.py 0 -- java Solution static class UnionFind { int[] parent; int[] rank; int n; UnionFind(int n) { this.n = n; parent = new int[n]; rank = new int[n]; for(int i=0;i<n;i++) { parent[i] = i; } } int find(int x) { if(parent[x] == x) return x; parent[x] = find(parent[x]); return parent[x]; } boolean union(int x,int y) { int rootX = find(x); int rootY = find(y); if(rootX == rootY) return false;; if(rank[rootX] > rank[rootY]) { parent[rootY] = rootX; } else if(rank[rootX] < rank[rootY]) { parent[rootX] = rootY; } else { parent[rootX] = rootY; rank[rootY]++; } return true; } } static void floydWarshall(int N, int[][] distArr) { for (int k = 0; k < N; k++) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if(distArr[i][k] != Integer.MAX_VALUE && distArr[k][j] != Integer.MAX_VALUE) { distArr[i][j] = Math.min(distArr[i][j], distArr[i][k] + distArr[k][j]); } } } } } static int[][] dirs = new int[][]{{1,0},{-1,0},{0,1},{0,-1}}; private static int M = (int)1e9+7; public static void main(String[] args) throws IOException { FastReader fr = new FastReader(); int numTestCases = fr.nextInt(); testCase: for (int testCase = 1; testCase <= numTestCases; testCase++) { long N = fr.nextLong(); long S = fr.nextLong(); long Nsquare = N * N; long ans = S / Nsquare; System.out.println(ans); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
f616a8f2c4ba1fc2ea8a3a9d589910ae
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; import java.io.*; public class B { static FastScanner fs = new FastScanner(); static PrintWriter pw = new PrintWriter(System.out); static StringBuilder sb = new StringBuilder(""); static int[] b = new int[1000001]; public static void main(String[] args) { int t = fs.nextInt(); for (int tt = 0; tt < t; tt++) { long n = fs.nextLong(); long s = fs.nextLong(); sb.append((s / (n * n)) + "\n"); } pw.print(sb.toString()); pw.close(); } static int kmp(String s, String sub) { int i = 0, j = 0, cnt = 0; int n = s.length(), m = sub.length(); kmpPreprocess(sub); while (i < n) { while (j >= 0 && s.charAt(i) != sub.charAt(j)) j = b[j]; i++; j++; if (j == m) { cnt++; j = b[j]; } } return cnt; } static void kmpPreprocess(String s) { int m = s.length(); int i = 0, j = -1; b[i] = -1; while (i < m) { if (j == -1 || s.charAt(i) == s.charAt(j)) { i++; j++; b[i] = j; } else { j = b[j]; } } } static void sort(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); } 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) {}return st.nextToken();} int nextInt() {return Integer.parseInt(next());} long nextLong() {return Long.parseLong(next());} double nextDouble() {return Double.parseDouble(next());} } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
3503115ad16f46d4a1c623a0ce83749f
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class squarecountonh { public static void main(String[] args) { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int t = sc.nextInt(); while (t-- > 0) { long n = sc.nextInt(); n = n * n; long sum = sc.nextLong(); long ans = sum / n; System.out.println(ans); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
3013a80a28676945f3ee47a7ce8be63d
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.*; import java.util.*; public class CF_774 { static FastScanner fs; static FastWriter fw; static boolean checkOnlineJudge = System.getProperty("ONLINE_JUDGE") == null; private static final int[][] kdir = new int[][]{{-1, 2}, {-2, 1}, {-2, -1}, {-1, -2}, {1, -2}, {2, -1}, {2, 1}, {1, 2}}; private static final int[][] dir = new int[][]{{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; private static final int iMax = (int) (1e9 + 100), iMin = (int) (-1e9 - 100); private static final long lMax = (long) (1e18 + 100), lMin = (long) (-1e18 - 100); private static final int mod1 = (int) (1e9 + 7); private static final int mod2 = 998244353; public static void main(String[] args) throws IOException { fs = new FastScanner(); fw = new FastWriter(); int t = 1; t = fs.nextInt(); while (t-- > 0) { solve(); } fw.out.close(); } private static void solve() { int n = fs.nextInt(); long s = fs.nextLong(); long n_squre = (long) n * n; long result = s / n_squre; fw.out.println(result); } private static class UnionFind { private final int[] parent; private final int[] rank; UnionFind(int n) { parent = new int[n + 5]; rank = new int[n + 5]; for (int i = 0; i <= n; i++) { parent[i] = i; rank[i] = 0; } } private int find(int i) { if (parent[i] == i) return i; return parent[i] = find(parent[i]); } private void union(int a, int b) { a = find(a); b = find(b); if (a != b) { if (rank[a] < rank[b]) { int temp = a; a = b; b = temp; } parent[b] = a; if (rank[a] == rank[b]) rank[a]++; } } } private static long gcd(long a, long b) { return (b == 0 ? a : gcd(b, a % b)); } private static long lcm(long a, long b) { return ((a * b) / gcd(a, b)); } private static long pow(long a, long b, int mod) { long result = 1; while (b > 0) { if ((b & 1L) == 1) { result = (result * a) % mod; } a = (a * a) % mod; b >>= 1; } return result; } private static long ceilDiv(long a, long b) { return ((a + b - 1) / b); } private static long getMin(long... args) { long min = lMax; for (long arg : args) min = Math.min(min, arg); return min; } private static long getMax(long... args) { long max = lMin; for (long arg : args) max = Math.max(max, arg); return max; } private static boolean isPalindrome(String s, int l, int r) { int i = l, j = r; while (j - i >= 1) { if (s.charAt(i) != s.charAt(j)) return false; i++; j--; } return true; } private static List<Integer> primes(int n) { boolean[] primeArr = new boolean[n + 5]; Arrays.fill(primeArr, true); for (int i = 2; (i * i) <= n; i++) { if (primeArr[i]) { for (int j = i * i; j <= n; j += i) { primeArr[j] = false; } } } List<Integer> primeList = new ArrayList<>(); for (int i = 2; i <= n; i++) { if (primeArr[i]) primeList.add(i); } return primeList; } private static class Pair<U, V> { private final U first; private final V second; @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> pair = (Pair<?, ?>) o; return first.equals(pair.first) && second.equals(pair.second); } @Override public int hashCode() { return Objects.hash(first, second); } @Override public String toString() { return "(" + first + ", " + second + ")"; } private Pair(U ff, V ss) { this.first = ff; this.second = ss; } } private static <T> void randomizeArr(T[] arr, int n) { Random r = new Random(); for (int i = (n - 1); i > 0; i--) { int j = r.nextInt(i + 1); swap(arr, i, j); } } private static Integer[] readIntArray(int n) { Integer[] arr = new Integer[n]; for (int i = 0; i < n; i++) arr[i] = fs.nextInt(); return arr; } private static List<Integer> readIntList(int n) { List<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) list.add(fs.nextInt()); return list; } private static <T> void swap(T[] arr, int i, int j) { T temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } private static <T> void displayArr(T[] arr) { for (T x : arr) fw.out.print(x + " "); fw.out.println(); } private static <T> void displayList(List<T> list) { for (T x : list) fw.out.print(x + " "); fw.out.println(); } private static class FastScanner { BufferedReader br; StringTokenizer st; FastScanner() throws IOException { if (checkOnlineJudge) this.br = new BufferedReader(new FileReader("src/input.txt")); else this.br = new BufferedReader(new InputStreamReader(System.in)); this.st = new StringTokenizer(""); } public String next() { while (!st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException err) { err.printStackTrace(); } } return st.nextToken(); } public String nextLine() { if (st.hasMoreTokens()) { return st.nextToken("").trim(); } try { return br.readLine().trim(); } catch (IOException err) { err.printStackTrace(); } return ""; } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } } private static class FastWriter { PrintWriter out; FastWriter() throws IOException { if (checkOnlineJudge) out = new PrintWriter(new FileWriter("src/output.txt")); else out = new PrintWriter(System.out); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
a009a42f2b6c62a9f6c13a73aee78704
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class squarecount { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while (T-- > 0) { int n = sc.nextInt(); long s = sc.nextLong(); long square = (long)n * n; long count = s / square; System.out.println(count); } sc.close(); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
7981a75b11e46428c59f2e11784e36ab
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Test { public static void main(String[] args) { FastReader scanner = new FastReader(); int t = scanner.nextInt(); for (int i = 0; i < t; i++) { long n = scanner.nextLong(); long s = scanner.nextLong(); System.out.println(s / (n * n)); } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
5cf66bee903a4b4cfa5437dff33ef8a4
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.*; import java.util.*; public class Solution{ 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(); } } static class Pair{ int a,b; Pair(int x, int y) { a=x; b= y; } } static class Interval{ long st,e; Interval(long x, long y) { st=x; e=y; } } static long mod = 1000000007; public static void main(String[] args) throws Exception { //Read input from user //Scanner scn = new Scanner(System.in); Reader scn = new Reader(); int t = scn.nextInt(); while(t>0) { long n = scn.nextLong(); long s = scn.nextLong(); long ans = s/(n*n); System.out.println(ans); t--; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
356343c8346cdefa481d85c8e74edee6
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner go = new Scanner(System.in); int t = go.nextInt(); while (t-->0){ int n = go.nextInt(); long s = go.nextLong(); long f = 0; if (s == 0){ System.out.println("0"); }else { f = s/((long) Math.pow(n,2)); System.out.println(f); } } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
806e95776ad1c560d7324321dd7da35c
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Ground1 { public static void main(String[] args) { Scanner myScanner = new Scanner(System.in); int cases = myScanner.nextInt(); for (int i = 0; i < cases; i++) { int n = myScanner.nextInt(); long s = myScanner.nextLong(); System.out.println(s / ((long) n * n)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
2630c3caac00a9adbfc82e508cd33c03
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.*; import java.net.Inet4Address; import java.nio.Buffer; import java.util.*; import java.text.*; import java.lang.*; public class a { static int[] arr; static int t; public static void main(String[] args) throws IOException{ BufferedReader inp = new BufferedReader(new InputStreamReader(System.in)); t = Integer.parseInt(inp.readLine()); for (int i = 0; i < t; i++) { StringTokenizer st = new StringTokenizer(inp.readLine()); solve(Integer.parseInt(st.nextToken()), Long.parseLong(st.nextToken())); } } static void solve(long n, long s) { System.out.println(s / (n * n)); } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
32b78f2fb9bfe9eb27263822aa45ab6a
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class A_Square_Counting{ public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ long n = sc.nextLong(); long s = sc.nextLong(); long square = n*n; System.out.println(s/square); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
9e32330418fda6ed2c9402cd07be3ee7
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.*; public class App { public static void main(String[] args) throws Exception { Scanner scanner =new Scanner(System.in); int T=scanner.nextInt(); for (int i = 0; i < T; i++) { Long number=scanner.nextLong(); long sum=scanner.nextLong(); System.out.println(sum/(number*number)); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
4269db0110cbba0ac7e8f6f681d796b1
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while (t-->0){ long n = scanner.nextInt(); long s = scanner.nextLong(); long sqN = n*n; long ans = s/sqN; System.out.println(ans); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
67122004af71de493ff15a10721c2c37
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); for (int i = 0; i < n; i++) { BigInteger nn = new BigInteger(in.next()); BigInteger s = new BigInteger(in.next()); System.out.println(s.divide(nn.pow(2))); } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
748dc348dda419ea87f5febc85f85bbb
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.*; import java.util.*; public class Solution { static int mod = 1000000007; public static void main(String[] args) throws FileNotFoundException { FastScanner fs = new FastScanner(); int t = fs.nextInt(); outer: while (t-- > 0) { long n = fs.nextLong(); long s = fs.nextLong(); long k = 0; k = s / (n * n); System.out.println(k); } } static boolean isPrime(int n) { if (n <= 1) return false; else if (n == 2) return true; else if (n % 2 == 0) return false; for (int i = 3; i <= Math.sqrt(n); i += 2) { if (n % i == 0) return false; } return true; } static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } static void sort(int[] a) { // suffle int n = a.length; Random r = new Random(); for (int i = 0; i < a.length; i++) { int oi = r.nextInt(n); int temp = a[i]; a[i] = a[oi]; a[oi] = temp; } // then sort Arrays.sort(a); } static long binpow(long a, long b, long m) { a %= m; long res = 1; while (b > 0) { if (b % 2 == 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } // Use this to input code since it is faster than a Scanner 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()); } ArrayList<Integer> readList(int n) { ArrayList<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) list.add(nextInt()); return list; } } static class Pair { String name; ArrayList<Integer> val; public Pair(String name, ArrayList<Integer> val) { this.name = name; this.val = val; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output
PASSED
6d99577f8cbfbdc8c2ab05d9a488da7c
train_110.jsonl
1646408100
Luis has a sequence of $$$n+1$$$ integers $$$a_1, a_2, \ldots, a_{n+1}$$$. For each $$$i = 1, 2, \ldots, n+1$$$ it is guaranteed that $$$0\leq a_i &lt; n$$$, or $$$a_i=n^2$$$. He has calculated the sum of all the elements of the sequence, and called this value $$$s$$$. Luis has lost his sequence, but he remembers the values of $$$n$$$ and $$$s$$$. Can you find the number of elements in the sequence that are equal to $$$n^2$$$?We can show that the answer is unique under the given constraints.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.*; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static PrintWriter out = new PrintWriter(System.out); static DecimalFormat df = new DecimalFormat("0.0000000"); final static int mod = (int) (1e9 + 7); final static int MAX = Integer.MAX_VALUE; final static int MIN = Integer.MIN_VALUE; static Random rand = new Random(); // ======================= MAIN ================================== public static void main(String[] args) throws IOException { // ==== start ==== int t = readInt(); // int t = 1; preprocess(); while (t-- > 0) { solve(); } out.flush(); } private static void solve() throws IOException { long n = readLong(); long s = readLong(); out.println(deal(n, s)); } static int deal(long n, long s) { long l = 0 , r = n+1; while(l < r){ long mid = (l+r)>>1; long sum = n*n*mid + (n+1-mid)*(n-1); if(sum < s){ l = mid+1; }else{ r = mid; } } return (int)l; } private static void preprocess() { } // ======================= FOR INPUT ================================== static String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(readLine()); return st.nextToken(); } static long readLong() throws IOException { return Long.parseLong(next()); } static int readInt() throws IOException { return Integer.parseInt(next()); } static double readDouble() throws IOException { return Double.parseDouble(next()); } static char readCharacter() throws IOException { return next().charAt(0); } static String readString() throws IOException { return next(); } static String readLine() throws IOException { return br.readLine().trim(); } static int[] readIntArray(int n) throws IOException { int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = readInt(); return arr; } static int[][] read2DIntArray(int n, int m) throws IOException { int[][] arr = new int[n][m]; for (int i = 0; i < n; i++) arr[i] = readIntArray(m); return arr; } static List<Integer> readIntList(int n) throws IOException { List<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) list.add(readInt()); return list; } static long[] readLongArray(int n) throws IOException { long[] arr = new long[n]; for (int i = 0; i < n; i++) arr[i] = readLong(); return arr; } static long[][] read2DLongArray(int n, int m) throws IOException { long[][] arr = new long[n][m]; for (int i = 0; i < n; i++) arr[i] = readLongArray(m); return arr; } static List<Long> readLongList(int n) throws IOException { List<Long> list = new ArrayList<>(); for (int i = 0; i < n; i++) list.add(readLong()); return list; } static char[] readCharArray(int n) throws IOException { return readString().toCharArray(); } static char[][] readMatrix(int n, int m) throws IOException { char[][] mat = new char[n][m]; for (int i = 0; i < n; i++) mat[i] = readCharArray(m); return mat; } // ========================= FOR OUTPUT ================================== private static void printIList(List<Integer> list) { for (int i = 0; i < list.size(); i++) out.print(list.get(i) + " "); out.println(" "); } private static void printLList(List<Long> list) { for (int i = 0; i < list.size(); i++) out.print(list.get(i) + " "); out.println(" "); } private static void printIArray(int[] arr) { for (int i = 0; i < arr.length; i++) out.print(arr[i] + " "); out.println(" "); } private static void print2DIArray(int[][] arr) { for (int i = 0; i < arr.length; i++) printIArray(arr[i]); } private static void printLArray(long[] arr) { for (int i = 0; i < arr.length; i++) out.print(arr[i] + " "); out.println(" "); } private static void print2DLArray(long[][] arr) { for (int i = 0; i < arr.length; i++) printLArray(arr[i]); } // ====================== TO CHECK IF STRING IS NUMBER ======================== private static boolean isInteger(String s) { try { Integer.parseInt(s); } catch (NumberFormatException e) { return false; } catch (NullPointerException e) { return false; } return true; } private static boolean isLong(String s) { try { Long.parseLong(s); } catch (NumberFormatException e) { return false; } catch (NullPointerException e) { return false; } return true; } // ==================== FASTER SORT ================================ private static void sort(int[] arr) { int n = arr.length; List<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) list.add(arr[i]); Collections.sort(list); for (int i = 0; i < n; i++) arr[i] = list.get(i); } private static void reverseSort(int[] arr) { int n = arr.length; List<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) list.add(arr[i]); Collections.sort(list, Collections.reverseOrder()); for (int i = 0; i < n; i++) arr[i] = list.get(i); } private static void sort(long[] arr) { int n = arr.length; List<Long> list = new ArrayList<>(); for (int i = 0; i < n; i++) list.add(arr[i]); Collections.sort(list); for (int i = 0; i < n; i++) arr[i] = list.get(i); } private static void reverseSort(long[] arr) { int n = arr.length; List<Long> list = new ArrayList<>(); for (int i = 0; i < n; i++) list.add(arr[i]); Collections.sort(list, Collections.reverseOrder()); for (int i = 0; i < n; i++) arr[i] = list.get(i); } // ==================== MATHEMATICAL FUNCTIONS =========================== private static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } private static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } private static int lcm(int a, int b) { return (a / gcd(a, b)) * b; } private static long lcm(long a, long b) { return (a / gcd(a, b)) * b; } private static long power(long a, long b) { if (b == 0) return 1L; long ans = power(a, b >> 1); ans *= ans; if ((b & 1) == 1) ans *= a; return ans; } private static int mod_power(int a, int b) { if (b == 0) return 1; int temp = mod_power(a, b / 2); temp %= mod; temp = (int) ((1L * temp * temp) % mod); if ((b & 1) == 1) temp = (int) ((1L * temp * a) % mod); return temp; } private static int multiply(int a, int b) { return (int) ((((1L * a) % mod) * ((1L * b) % mod)) % mod); } private static boolean isPrime(long n) { for (long i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } private static long nCr(long n, long r) { if (n - r > r) r = n - r; long ans = 1L; for (long i = r + 1; i <= n; i++) ans *= i; for (long i = 2; i <= n - r; i++) ans /= i; return ans; } // ==================== Primes using Seive ===================== private static List<Integer> getPrime(int n) { boolean[] prime = new boolean[n + 1]; Arrays.fill(prime, true); for (int i = 2; i * i <= n; i++) { if (prime[i]) { for (int j = i * i; j <= n; j += i) prime[j] = false; } } // return prime; List<Integer> list = new ArrayList<>(); for (int i = 2; i <= n; i++) if (prime[i]) list.add(i); return list; } private static int[] SeivePrime() { int n = (int) 1e6 + 1; int[] primes = new int[n]; for (int i = 0; i < n; i++) primes[i] = i; for (int i = 2; i * i < n; i++) { if (primes[i] != i) continue; for (int j = i * i; j < n; j += i) { if (primes[j] == j) primes[j] = i; } } return primes; } // ==================== STRING FUNCTIONS ================================ private static boolean isPalindrome(String str) { int i = 0, j = str.length() - 1; while (i < j) if (str.charAt(i++) != str.charAt(j--)) return false; return true; } private static String reverseString(String str) { StringBuilder sb = new StringBuilder(str); return sb.reverse().toString(); } private static String sortString(String str) { int[] arr = new int[256]; for (char ch : str.toCharArray()) arr[ch]++; StringBuilder sb = new StringBuilder(); for (int i = 0; i < 256; i++) while (arr[i]-- > 0) sb.append((char) i); return sb.toString(); } // ==================== LIS & LNDS ================================ private static int LIS(int arr[], int n) { List<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) { int idx = find(list, arr[i]); if (idx < list.size()) list.set(idx, arr[i]); else list.add(arr[i]); } return list.size(); } private static int find(List<Integer> list, int val) { int ret = list.size(), i = 0, j = list.size() - 1; while (i <= j) { int mid = (i + j) / 2; if (list.get(mid) >= val) { ret = mid; j = mid - 1; } else { i = mid + 1; } } return ret; } private static int LNDS(int[] arr, int n) { List<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) { int idx = find2(list, arr[i]); if (idx < list.size()) list.set(idx, arr[i]); else list.add(arr[i]); } return list.size(); } private static int find2(List<Integer> list, int val) { int ret = list.size(), i = 0, j = list.size() - 1; while (i <= j) { int mid = (i + j) / 2; if (list.get(mid) <= val) { i = mid + 1; } else { ret = mid; j = mid - 1; } } return ret; } // ==================== UNION FIND ===================== private static int find(int x, int[] parent) { if (parent[x] == x) return x; return parent[x] = find(parent[x], parent); } private static boolean union(int x, int y, int[] parent, int[] rank) { int lx = find(x, parent), ly = find(y, parent); if (lx == ly) return true; if (rank[lx] > rank[ly]) parent[ly] = lx; else if (rank[lx] < rank[ly]) parent[lx] = ly; else { parent[lx] = ly; rank[ly]++; } return false; } // ==================== SEGMENT TREE (RANGE SUM) ===================== public static class SegmentTree { int n; int[] arr, tree, lazy; SegmentTree(int arr[]) { this.arr = arr; this.n = arr.length; this.tree = new int[(n << 2)]; this.lazy = new int[(n << 2)]; build(1, 0, n - 1); } void build(int id, int start, int end) { if (start == end) tree[id] = arr[start]; else { int mid = (start + end) / 2, left = (id << 1), right = left + 1; build(left, start, mid); build(right, mid + 1, end); tree[id] = tree[left] + tree[right]; } } void update(int l, int r, int val) { update(1, 0, n - 1, l, r, val); } void update(int id, int start, int end, int l, int r, int val) { distribute(id, start, end); if (end < l || r < start) return; if (start == end) tree[id] += val; else if (l <= start && end <= r) { lazy[id] += val; distribute(id, start, end); } else { int mid = (start + end) / 2, left = (id << 1), right = left + 1; update(left, start, mid, l, r, val); update(right, mid + 1, end, l, r, val); tree[id] = tree[left] + tree[right]; } } int query(int l, int r) { return query(1, 0, n - 1, l, r); } int query(int id, int start, int end, int l, int r) { if (end < l || r < start) return 0; distribute(id, start, end); if (start == end) return tree[id]; else if (l <= start && end <= r) return tree[id]; else { int mid = (start + end) / 2, left = (id << 1), right = left + 1; return query(left, start, mid, l, r) + query(right, mid + 1, end, l, r); } } void distribute(int id, int start, int end) { if (start == end) tree[id] += lazy[id]; else { tree[id] += lazy[id] * (end - start + 1); lazy[(id << 1)] += lazy[id]; lazy[(id << 1) + 1] += lazy[id]; } lazy[id] = 0; } } // ==================== TRIE ================================ static class Trie { class Node { Node[] children; boolean isEnd; Node() { children = new Node[26]; } } Node root; Trie() { root = new Node(); } public void insert(String word) { Node curr = root; for (char ch : word.toCharArray()) { if (curr.children[ch - 'a'] == null) curr.children[ch - 'a'] = new Node(); curr = curr.children[ch - 'a']; } curr.isEnd = true; } public boolean find(String word) { Node curr = root; for (char ch : word.toCharArray()) { if (curr.children[ch - 'a'] == null) return false; curr = curr.children[ch - 'a']; } return curr.isEnd; } } // ==================== FENWICK TREE ================================ static class FT { long[] tree; int n; FT(int[] arr, int n) { this.n = n; this.tree = new long[n + 1]; for (int i = 1; i <= n; i++) { update(i, arr[i - 1]); } } void update(int idx, int val) { while (idx <= n) { tree[idx] += val; idx += idx & -idx; } } long query(int l, int r) { return getSum(r) - getSum(l - 1); } long getSum(int idx) { long ans = 0L; while (idx > 0) { ans += tree[idx]; idx -= idx & -idx; } return ans; } } // ==================== BINARY INDEX TREE ================================ static class BIT { long[][] tree; int n, m; BIT(int[][] mat, int n, int m) { this.n = n; this.m = m; tree = new long[n + 1][m + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { update(i, j, mat[i - 1][j - 1]); } } } void update(int x, int y, int val) { while (x <= n) { int t = y; while (t <= m) { tree[x][t] += val; t += t & -t; } x += x & -x; } } long query(int x1, int y1, int x2, int y2) { return getSum(x2, y2) - getSum(x1 - 1, y2) - getSum(x2, y1 - 1) + getSum(x1 - 1, y1 - 1); } long getSum(int x, int y) { long ans = 0L; while (x > 0) { int t = y; while (t > 0) { ans += tree[x][t]; t -= t & -t; } x -= x & -x; } return ans; } } // ==================== OTHER CLASSES ================================ static class Pair implements Comparable<Pair> { int first, second; Pair(int first, int second) { this.first = first; this.second = second; } public int compareTo(Pair o) { return this.first - o.first; } } static class DequeNode { DequeNode prev, next; int val; DequeNode(int val) { this.val = val; } DequeNode(int val, DequeNode prev, DequeNode next) { this.val = val; this.prev = prev; this.next = next; } } }
Java
["4\n\n7 0\n\n1 1\n\n2 12\n\n3 12"]
1 second
["0\n1\n3\n1"]
NoteIn the first test case, we have $$$s=0$$$ so all numbers are equal to $$$0$$$ and there isn't any number equal to $$$49$$$.In the second test case, we have $$$s=1$$$. There are two possible sequences: $$$[0, 1]$$$ or $$$[1, 0]$$$. In both cases, the number $$$1$$$ appears just once. In the third test case, we have $$$s=12$$$, which is the maximum possible value of $$$s$$$ for this case. Thus, the number $$$4$$$ appears $$$3$$$ times in the sequence.
Java 11
standard input
[ "math" ]
7226a7d2700ee52f52d417f404c42ab7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1\le n&lt; 10^6$$$, $$$0\le s \le 10^{18}$$$). It is guaranteed that the value of $$$s$$$ is a valid sum for some sequence satisfying the above constraints.
800
For each test case, print one integer — the number of elements in the sequence which are equal to $$$n^2$$$.
standard output