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 | b591ecfa4781512baa76fe96e2d35ad9 | 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 < 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.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Random;
import java.util.StringTokenizer;
public class nsquare {
static long power(long pow, long pow2, long mod)
{
long res = 1; // Initialize result
pow = pow % mod; // Update x if it is more than or
// equal to p
if (pow == 0)
return 0; // In case x is divisible by p;
while (pow2 > 0)
{
// If y is odd, multiply x with result
if ((pow2 & 1) != 0)
res = (res * pow) % mod;
// y must be even now
pow2 = pow2 >> 1; // y = y/2
pow = (pow * pow) % mod;
}
return res;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
StringBuilder st = new StringBuilder();
FastReader sc = new FastReader();
int t=sc.nextInt();
while (t-- != 0) {
long n=sc.nextLong();
long s=sc.nextLong();
if(s==0&&n>0||s<n)
{
st.append(0+"\n");
}
else if(s>=(n+1)*pow(n))
{
st.append(n+1+"\n");
}
else{
long sum=s;
long count=0;
if(sum>=pow(n))
{
count=sum/(pow(n));
}
else{
count=0;
}
st.append(count+"\n");
}
}
System.out.println(st);
}
static long pow(long n)
{
long ans=n*n;
return ans;
}
static FastReader sc = new FastReader();
public static void solvegraph() {
int n = sc.nextInt();
int edge[][] = new int[n - 1][2];
for (int i = 0; i < n - 1; i++) {
edge[i][0] = sc.nextInt() - 1;
edge[i][1] = sc.nextInt() - 1;
}
ArrayList<ArrayList<Integer>> ad = new ArrayList<>();
for (int i = 0; i < n; i++) {
ad.add(new ArrayList<Integer>());
}
for (int i = 0; i < n - 1; i++) {
ad.get(edge[i][0]).add(edge[i][1]);
ad.get(edge[i][1]).add(edge[i][0]);
}
int parent[] = new int[n];
Arrays.fill(parent, -1);
parent[0] = n;
ArrayDeque<Integer> queue = new ArrayDeque<>();
queue.add(0);
int child[] = new int[n];
Arrays.fill(child, 0);
ArrayList<Integer> lv = new ArrayList<Integer>();
while (!queue.isEmpty()) {
int toget = queue.getFirst();
queue.removeFirst();
child[toget] = ad.get(toget).size() - 1;
for (int i = 0; i < ad.get(toget).size(); i++) {
if (parent[ad.get(toget).get(i)] == -1) {
parent[ad.get(toget).get(i)] = toget;
queue.addLast(ad.get(toget).get(i));
}
}
lv.add(toget);
}
child[0]++;
}
static void sort(int[] A) {
int n = A.length;
Random rnd = new Random();
for (int i = 0; i < n; ++i) {
int tmp = A[i];
int randomPos = i + rnd.nextInt(n - i);
A[i] = A[randomPos];
A[randomPos] = tmp;
}
Arrays.sort(A);
}
static void sort(long[] A) {
int n = A.length;
Random rnd = new Random();
for (int i = 0; i < n; ++i) {
long tmp = A[i];
int randomPos = i + rnd.nextInt(n - i);
A[i] = A[randomPos];
A[randomPos] = tmp;
}
Arrays.sort(A);
}
static String sort(String s) {
Character ch[] = new Character[s.length()];
for (int i = 0; i < s.length(); i++) {
ch[i] = s.charAt(i);
}
Arrays.sort(ch);
StringBuffer st = new StringBuffer("");
for (int i = 0; i < s.length(); i++) {
st.append(ch[i]);
}
return st.toString();
}
public static long gcd(long a, long b) {
if (a == 0) {
return b;
}
return gcd(b % a, a);
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["4\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< 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 | ca3ab61230d8e1e395f2db94610a7094 | 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 < 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.*;
import java.math.BigInteger;
public class Main
{
InputStream is;
PrintWriter out = new PrintWriter(System.out); ;
String INPUT = "";
void run() throws Exception
{
is = System.in;
solve();
out.flush();
out.close();
}
public static void main(String[] args) throws Exception { new Main().run(); }
public byte[] inbuf = new byte[1024];
public int lenbuf = 0, ptrbuf = 0;
public int readByte()
{
if(lenbuf == -1)throw new InputMismatchException();
if(ptrbuf >= lenbuf){ ptrbuf = 0;
try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; }
public boolean isSpaceChar(int c)
{
return !(c >= 33 && c <= 126);
}
public int skip()
{
int b;
while((b = readByte()) != -1 && isSpaceChar(b));
return b;
}
public double nd()
{
return Double.parseDouble(ns());
}
public char nc()
{
return (char)skip();
}
private String ns()
{
int b = skip();
StringBuilder sb = new StringBuilder();
while(!(isSpaceChar(b)))
{
sb.appendCodePoint(b); b = readByte();
}
return sb.toString();
}
private int ni()
{
return (int)nl();
}
private long nl()
{
long num = 0;
int b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-')
{
minus = true; b = readByte();
}
while(true)
{
if(b >= '0' && b <= '9')
{
num = num * 10 + (b - '0');
}
else { return minus ? -num : num; } b = readByte();
}
}
class Pair
{
int first;
int second;
Pair(int a, int b)
{
first = a;
second = b;
}
}
// KMP ALGORITHM
void KMPSearch(String pat, String txt) {
int M = pat.length(); int N = txt.length();
int lps[] = new int[M]; int j = 0;
computeLPSArray(pat, M, lps); int i = 0;
while (i < N) {
if (pat.charAt(j) == txt.charAt(i)) {
j++;
i++;
}
if (j == M) {
j = lps[j - 1];
}
else if (i < N && pat.charAt(j) != txt.charAt(i)) {
if (j != 0) j = lps[j - 1];
else i = i + 1;
}
}
}
void computeLPSArray(String pat, int M, int lps[]) {
int len = 0; int i = 1; lps[0] = 0;
while (i < M) {
if (pat.charAt(i) == pat.charAt(len)) {
len++;
lps[i] = len;
i++;
}
else {
if (len != 0) {
len = lps[len - 1];
}
else {
lps[i] = len;
i++;
}
}
}
}
int FirstAndLastOccurrenceOfAnElement(int[] arr, int target, boolean findStartIndex)
{
int ans = -1;
int n = arr.length;
int low = 0; int high = n-1;
while(low <= high)
{
int mid = low + (high - low)/2;
if(arr[mid] > target) high = mid-1;
else if(arr[mid] < target) low = mid+1;
else
{
ans = mid;
if(findStartIndex) high = mid-1;
else low = mid+1;
}
}
return ans;
}
int[] na(int n)
{
int[] arr = new int[n];
for(int i=0; i<n; i++) arr[i]=ni();
return arr;
}
long[] nal(int n)
{
long[] arr = new long[n];
for(int i=0; i<n; i++) arr[i]=nl();
return arr;
}
void solve()
{
int t = ni();
while(t-- > 0)
{
long n = nl(); long s = nl();
long count = 0;
long p = n*n;
count = s/p;
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< 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 | 296a5639c7cc6f6e8d6d1105d16aa3ec | 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 < 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 Solving {
public static void main(String[] args) {
Scanner moad=new Scanner(System.in);
int t;
t=moad.nextInt();
while(t>0)
{
long n,s,c;
n=moad.nextLong();
s=moad.nextLong();
c=s/(n*n);
if(c>n+1)
System.out.println(s/(n-1));
else
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< 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 | 2979851f73a081522104c5c31e021353 | 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 < 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 Space
{
public static void main(String[] args) {
Scanner moad=new Scanner(System.in);
int t;
t=moad.nextInt();
while(t>0)
{
long n,s,c;
n=moad.nextLong();
s=moad.nextLong();
c=s/(n*n);
if(c>n+1)
System.out.println(s/(n-1));
else
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< 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 | 57ffa8eacacc4d50cfaa495bd448207a | 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 < 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 D {
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 temp=n*n;
n++;
long p=s/temp;
System.out.println(p);
}
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< 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 | 88bc3a4ea16944bb854472678f57f1cc | 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 < 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.ArrayList;
import java.util.Scanner;
public class SquareCounting {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
long cases=scanner.nextLong();
ArrayList<SandN> arrayList=new ArrayList<>();
for (int i = 0; i < cases; i++) {
long n=scanner.nextLong();
long s=scanner.nextLong();
arrayList.add(new SandN(n,s));
}
for (SandN o : arrayList) {
System.out.println(o.numberOfSquares());
}
}
public static class SandN {
private long s;
private long n;
public SandN( long n,long s) {
this.s = s;
this.n = n;
}
public long numberOfSquares() {
return n!=0 ? s/(n*n) : 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< 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 | 9652082ed836d1b9664b28ec165196fb | 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 < 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 example {
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 sc = new FastReader() ;
long t = sc.nextLong() ;
while(t-- != 0 ) {
long n = sc.nextLong() ;
long s = sc.nextLong() ;
if(s<n*n)
{
System.out.println(0);
}
else System.out.println(s/(n*n));
}
}// main method ends
static boolean isPrime(long n)
{
// Corner cases
if (n <= 1)
return false;
if (n <= 3)
return true;
// This is checked so that we can skip
// middle five numbers in below loop
if (n % 2 == 0 || n % 3 == 0)
return false;
for (int i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
}//class ends
| 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< 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 | 89dc49e8d3ca23d4f75db874ff87be7f | 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 < 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) {
Scanner sc = new Scanner(System.in);
long t= sc.nextLong();
for(long i=0;i<t;i++){
long n= sc.nextLong();
if(n==0)System.out.println(0);
else{
long s= sc.nextLong();
long ans= s/(n*n);
System.out.println(ans);
}
}
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< 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 | bebc88a803212abb570acff8303e36b0 | 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 < 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.StringTokenizer;
public class CountSquares {
public static void main(String[] args) throws IOException {
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
for (int i = 0; i < n; i++) {
st = new StringTokenizer(br.readLine());
long a = Long.parseLong(st.nextToken());
long b = Long.parseLong(st.nextToken());
if (b == 0) bw.write(0 + "\n");
else {
long cnt = a * a;
long res = b / cnt;
bw.write(res + "\n");
}
}
bw.flush();
bw.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< 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 | fa090a7dc5154bd3e90114e1513c8fed | 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 < 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 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< 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 | eaf98fc3130b57eec6ec23d7bdc83870 | 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 < 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 f{
static void f(int []a,int n,ArrayList<Integer> al,boolean []b){
if(al.size()==n){
System.out.println(al);
return ;
}
for(int j=0;j<n;j++){
if(!b[j]){
b[j]=true;
al.add(a[j]);
f(a,n,al,b);
al.remove(al.size()-1);
b[j]=false;
}
}
}
public static void main(String ...asada){
// // int []a={1,2,3};
// // boolean []b=new boolean[3];
// // f(a,a.length,new ArrayList<Integer>(),b);
// String a="132",b="8";
// //System.out.println(a.compareTo(b));
// Map<Character,Integer> m=new LinkedHashMap<>();
// String s="saminenivamshi";
// for(int i=0;i<s.length();i++)
// m.put(s.charAt(i),m.getOrDefault(s.charAt(i),0)+1);
// for(Map.Entry<Character,Integer> e:m.entrySet())
// System.out.println(e.getKey()+" "+e.getValue());
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
long n=sc.nextLong();
long s=sc.nextLong();
long p=s/(n*n);
if(p>=n+1)
System.out.println(n+1);
else
System.out.println(p);
}
}
}
| 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< 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 | cfd11d881184c5170b548dcc387bcb52 | 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 < 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) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt(),ans;
while(t-- >0){
long n=sc.nextLong();
long s=sc.nextLong();
// if(s==1L)
// System.out.println(1);
// else{
if(s/(n*n)>n+1L) System.out.println(n+1);
else
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< 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 | 345e10ab027f4c2e26eaa206b8476e8b | 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 < 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 | /**
This is Lazy Genius
HALAL MODE ON
HARAM MODE OFF
MADE BY SomeOne
**/
import java.util.*;
import java.io.*;
public class Max {
public static void main(String[] args) {
int t = scan.nextInt();
while(t-->0){
solve();
}
}
static Scanner scan = new Scanner(System.in);
public static void solve(){
long n = scan.nextLong();
long s = scan.nextLong();
long a = (long)(n*n);
if(s/a ==n+1){
System.out.println(n+1);
}else{
System.out.println(s/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 8 | 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< 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 | 21f3bfcc03073c84cb66cb32debb9d98 | 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 < 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 {
//https://codeforces.com/contest/1646/problem/0
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
long n,sum;
while(t-- >0){
n=sc.nextLong();
sum= sc.nextLong();
System.out.println(sum/(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 8 | 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< 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 | 1369e979f1713febf5d230429e8902c6 | 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 < 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 | //package kriti;
import java.io.*;
//findindex
//checkTriangle
import java.util.*;
//isSorted
//isPrime
//print
//sort
//input
public class A
{
static PrintWriter out = new PrintWriter(System.out);
static StringBuilder ans=new StringBuilder();
static FastReader in=new FastReader();
public static void main(String args[])throws IOException
{
int t=i();
while(t-->0) {
long n=l();
long s=l();
long sq=(n*n);
if(s<sq) {
System.out.println(0);
continue;
}
System.out.println(s/sq);
}
}
public static int findindex(int[] arr, int val) {
for(int i=0;i<arr.length;i++) {
if(val==arr[i]) {
return i+1;
}
}
return -1;
}
public static int checkTriangle(long a,
long b, long c)
{
// check condition
if (a + b <= c || a + c <= b || b + c <= a)
return 0;
else
return 1;
}
static boolean isSorted(long A[])
{
for(int i=1; i<A.length; i++)if(A[i]<A[i-1])return false;
return true;
}
static int kadane(int A[])
{
int lsum=A[0],gsum=A[0];
for(int i=1; i<A.length; i++)
{
lsum=Math.max(lsum+A[i],A[i]);
gsum=Math.max(gsum,lsum);
}
return gsum;
}
static void print(char A[])
{
for(char c:A)System.out.print(c);
System.out.println();
}
static void print(boolean A[])
{
for(boolean c:A)System.out.print(c+" ");
System.out.println();
}
static void print(int A[])
{
for(int a:A)System.out.print(a+" ");
System.out.println();
}
static void print(long A[])
{
for(long i:A)System.out.print(i+ " ");
System.out.println();
}
static void print(ArrayList<Long> A)
{
for(long a:A)System.out.print(a+" ");
System.out.println();
}
static void sort(long[] a) //check for long
{
ArrayList<Long> l=new ArrayList<>();
for (long i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static boolean isPrime(long N)
{
if (N<=1) return false;
if (N<=3) return true;
if (N%2 == 0 || N%3 == 0) return false;
for (int i=5; i*i<=N; i=i+6)
if (N%i == 0 || N%(i+2) == 0)
return false;
return true;
}
static long GCD(long a,long b)
{
if(b==0)
{
return a;
}
else return GCD(b,a%b );
}
static int i()
{
return in.nextInt();
}
static long l()
{
return in.nextLong();
}
static String S() {
return in.next();
}
static int[] input(int N){
int A[]=new int[N];
for(int i=0; i<N; i++)
{
A[i]=in.nextInt();
}
return A;
}
static long[] inputLong(int N) {
long A[]=new long[N];
for(int i=0; i<A.length; i++)A[i]=in.nextLong();
return A;
}
}
class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br=new BufferedReader(new InputStreamReader(System.in));
}
String next()
{
while(st==null || !st.hasMoreElements())
{
try
{
st=new StringTokenizer(br.readLine());
}
catch(IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str="";
try
{
str=br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
| Java | ["4\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 8 | 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< 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 | b4b7626323deba39e9cc9033e02123f0 | 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 < 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 in = new Scanner(System.in);
long n = in.nextLong();
while (n-- > 0) {
long s1=in.nextLong();
long s=in.nextLong();
long sum=s1*s1;
long sum2=s/sum;
System.out.println(sum2);
}
}
}
| 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 8 | 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< 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 | 236cd9ce4b3d9bdf6e0fc61b5825729f | 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 < 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 taskO4O3 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int t = console.nextInt();
for (int i = 0; i < t; i++) {
long n = console.nextLong();
long s = console.nextLong();
long nn = s/(n*n);
if (nn <= n || (s%(n*n)==0 && nn <= n+1))
System.out.println(nn);
else
System.out.println(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 8 | 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< 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 | a46ebdb2b01184f96aa6b2476e2267d4 | 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 < 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 Cf {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args ) {
int t = sc.nextInt();
while (t-- > 0) {
long n;
long s;
n = sc.nextLong(); s = sc.nextLong();
System.out.println(s / (n * n));
}
}
}
// 0, 1, 2,
/*
n^2 = 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 8 | 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< 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 | 0ce4eb741dd3e1d8799d708b05149a3a | 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 < 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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class round {
static PrintWriter pw = new PrintWriter(System.out);
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) throws IOException {
int x = sc.nextInt();
while (x-- > 0) {
long n = sc.nextLong();
long s = sc.nextLong();
pw.println((long) (Math.floor(s / (n*n))));
}
pw.flush();
pw.close();
}
}
class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public boolean ready() throws IOException {
return br.ready();
}
}
| 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 8 | 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< 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 | 480c25eadea4a6bd4e9d1383eb8fd743 | 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 < 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 qu1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while( t-->0)
{
long n= sc.nextInt();
long s = sc.nextLong();
long h= (long) Math.pow(n, 2);
long d = s/h ;
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 8 | 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< 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 | 084ce2fb0a7d8d169749454834757ef0 | 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 < 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(),s=sc.nextLong(),k=n*n;
System.out.println(s/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 8 | 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< 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 | ebdb4cb3465ed22e31518815f9f19cc8 | 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 < 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 bbb {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-- > 0) {
long n = in.nextLong();
long s = in.nextLong();
long c =s/(n*n);
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 8 | 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< 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 | 648fdb827a9048a5c886336e34401519 | 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 < 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 | /*#####################################################
################ >>>> Diaa12360 <<<< ##################
################ Just Nothing ##################
############ If You Need it, Fight For IT; ############
####################.-. 1 5 9 2 .-.####################
######################################################*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
StringBuilder out = new StringBuilder();
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tk;
int t = Int(in.readLine());
while(t-- > 0) {
tk = new StringTokenizer(in.readLine());
long n = Lon(tk.nextToken()), s = Lon(tk.nextToken());
if(s == 0)
out.append(0).append('\n');
else if(s >= n ){
long sum = s/(n*n);
out.append(sum).append('\n');
}
else out.append(0).append('\n');
}
System.out.print(out);
}
static int Int(String s) {return Integer.parseInt(s);}
static long Lon(String s) {return Long.parseLong(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 8 | 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< 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 | a6288fe48e017389de8e1315a10eb796 | 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 < 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.*;
public class Main {
public static void main(String[] args) {
Scanner ss=new Scanner(System.in);
int number =ss.nextInt();
for(int i=1;i<=number;i++){
long x=ss.nextLong();
long s=ss.nextLong();
long result=s/(x * x);
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 8 | 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< 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 | fafe500f79e855ec1aa260a7a2cc13be | 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 < 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 | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public*/
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// try {
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// int t = Integer.parseInt(br.readLine());
// while(t-- > 0) {
// long n = Long.parseLong(br.readLine());
// long s = Long.parseLong(br.readLine());
// long sum=0, itr=-1;
// // if(n > s) {
// // System.out.println(0);
// // }
// // else {
// // while(sum <= s) {
// // sum += Math.pow(n,2);
// // itr++;
// // }
// // System.out.println(itr);
// // }
// // }
// long ans=s/n*n;
// System.out.println(ans);
// }
// } catch(Exception e) {
// }
try {
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);
}
} catch(Exception e) {
}
// your code goes here
}
}
| 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 8 | 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< 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 | 434f1433dc65b4f7f4bbb0ecb9dc515d | 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 < 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 {
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));
// int[] arr = new int[n];
// int c=n-1;
// for(int i=0;i<n;i++){
// arr[i] = sc.nextInt();
// if(i>0 && arr[i] == arr[i-1] && arr[i] == 1){
// c--;
// }
// }
// 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 8 | 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< 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 | a815a08195e3102b35e572f402aef0be | 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 < 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 | //package com.company;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.StringTokenizer;
public class SquareCounting {
public static void main(String[] args) throws IOException{
FastScaner fs = new FastScaner();
int t = fs.nextInt();
for(int tt=0;tt<t;tt++){
long n = fs.nextLong();
long s = fs.nextLong();
System.out.println(s / (n * n));
}
}
static final Random random = new Random();
static final int mod = 1_000_000_007;
//Taken From "Second Thread"
static void ruffleSort(int[] a){
int n = a.length;//shuffles, then sort;
for(int i=0; i<n; i++){
int oi = random.nextInt(n), temp = a[oi];
a[oi] = a[i]; a[i] = temp;
}
}
static class FastScaner{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public String next(){
while(!st.hasMoreTokens()){
try{
st = new StringTokenizer(br.readLine());
}catch (IOException e){
e.printStackTrace();
}
}
return st.nextToken();
}
public int[] readArray(int n){
int[] a = new int[n];
for(int i=0; i<n; i++)a[i] = nextInt();
return a;
}
public int nextInt(){
return Integer.parseInt(next());
}
public long nextLong(){
return Long.parseLong(next());
}
public double nextDouble(){
return Double.parseDouble(next());
}
public float nextFloat(){
return Float.parseFloat(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 8 | 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< 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 | e9fe06eaa5e4a27906d56da76595ad48 | 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 < 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);
long t = sc.nextLong();
while (t-- > 0) {
long n = sc.nextLong();
long s = sc.nextLong();
long n_square = n * n;
if (n == 0) {
System.out.println(0);
continue;
}
long ans = (long) s / n_square;
System.out.println(ans);
// System.out.println(1);
}
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 8 | 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< 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 | 79afbcf9ede07536db4c04981df9d42f | 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 < 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 code {
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 = Long.parseUnsignedLong(sc.next());
if(n==0) System.out.println(0);
else {
Long d = s / ((long) n * n);
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 8 | 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< 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 | 97297e7a2528ec5273cebf7ec984af76 | 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 < 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_1ch {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
long y = sc.nextLong();
long x = sc.nextLong();
long z;
z = x / (y * y);
System.out.println(z);
}
}
} | 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 8 | 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< 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 | 1a6d05f786ce143637778012715b36c6 | 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 < 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_1ch {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
long y = sc.nextLong();
long x = sc.nextLong();
long z;
z = x / (y * y);
System.out.println(z);
}
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 8 | 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< 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 | fe763063b19bcc0b3d441d0a7beac50d | 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 < 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.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;
public class A {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(
new FileReader("input.txt"));
PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
} catch (Exception e) {
br = new BufferedReader(new InputStreamReader(System.in));
}
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
// end of fast i/o code
//---------------fast reader code ends---------------------------------------------------------
//-----Fenwick Tree or Binary Indexed Tree----------------------------------------------------
static class Fenwick
{
private int fenTree[] = null, size;
Fenwick(int size)
{
this.size = size + 1;
fenTree = new int[size + 1];
}
public void add(int val, int indx)
{
indx++;
while(indx < this.size)
{
fenTree[indx] += val;
indx += (indx & (-indx)); //adding the last set bit
}
}
//upto which index you want prefix sum
public int getPrefSum(int indx)
{
int sum = 0;
indx++;
while(indx > 0)
{
sum += fenTree[indx];
indx -= (indx & (-indx)); //turning off the last set bit
}
return sum;
}
}
//-----------Disjoint set / Union-find-----------------------------------------------
static class DisjointSet
{
int parent[] = null;
int ranks[] = null;
DisjointSet(int len)
{
parent = new int[len];
ranks = new int[len];
for (int indx = 0; indx < parent.length; indx++)
{
parent[indx] = indx;
ranks[indx] = 0;
}
}
// Time complexity: O(Alpha(n)), Alpha(n) <= 4, therefore O(1) and auxiliary
// space: O(1) for recursion stack
public void union(int x, int y)
{
int xRep = find(x);
int yRep = find(y);
if (xRep == yRep)
return;
if (ranks[xRep] < ranks[yRep])
parent[xRep] = yRep;
else if (ranks[yRep] < ranks[xRep])
parent[yRep] = xRep;
else
{
parent[yRep] = xRep;
ranks[xRep]++;
}
}
// Time complexity: O(LogN) and auxiliary space: O(1) for recursion stack
public int find(int x)
{
if (parent[x] == x)
{
return x;
}
return parent[x] = find(parent[x]);
}
}
//-------GCD & LCM Section-----------------------------------------------------------------
private static int findGCDArr(int arr[], int n)
{
int result = arr[0];
for (int element: arr){
result = gcd(result, element);
if(result == 1)
{
return 1;
}
}
return result;
}
private static int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
public static BigInteger bigLcm(String a, String b)
{
// convert string 'a' and 'b' into BigInteger
BigInteger s = new BigInteger(a);
BigInteger s1 = new BigInteger(b);
// calculate multiplication of two bigintegers
BigInteger mul = s.multiply(s1);
// calculate gcd of two bigintegers
BigInteger gcd = s.gcd(s1);
// calculate lcm using formula: lcm * gcd = x * y
BigInteger lcm = mul.divide(gcd);
BigInteger lc = lcm.divide(s);
return lc;
}
private static int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
static List<Integer> findFactors(int n)
{
List<Integer> res = new ArrayList<>();
// Note that this loop runs till square root
for (int i=1; i<=Math.sqrt(n); i++)
{
if (n%i==0)
{
// If divisors are equal, add only one
if (n/i == i)
res.add(i);
else // Otherwise add both
res.add(i);
res.add(n/i);
}
}
return res;
}
//-----------------------------------------------------------------------------------------
//--------------------------binary exponentiation or power with modulo m-------------------
private static long binPow(int a, int b, int m){
if(b==0){
return a%m;
}
if(b % 2 == 0){
long pw = binPow(a, b/2, m);
return (1l * pw * pw % m);
}else{
long pw = binPow(a, (b-1)/2, m);
return 1l * pw * pw * a % m;
}
}
private static long mulInvMod(int x, int m){
return binPow(x, m-2, m);
}
//*****************************************************************************************
//--------------------------------Template ends--------------------------------------------
public static void main(String[] args) {
FastReader reader = new FastReader();
int t = reader.nextInt();
for(int tt = 1; tt<=t; tt++){
long n = reader.nextLong();
long sum = reader.nextLong();
long nSq = (long)Math.pow(n, 2);
long cnt = (long)Math.floor(sum/nSq);
System.out.println(cnt);
// System.out.println(sum/(n*n));//this works
}
}
} | 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 8 | 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< 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 | edf5c1f7d2e32d66bde2913500dd6bd2 | 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 < 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.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;
public class A {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(
new FileReader("input.txt"));
PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
} catch (Exception e) {
br = new BufferedReader(new InputStreamReader(System.in));
}
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
// end of fast i/o code
//---------------fast reader code ends---------------------------------------------------------
//-----Fenwick Tree or Binary Indexed Tree----------------------------------------------------
static class Fenwick
{
private int fenTree[] = null, size;
Fenwick(int size)
{
this.size = size + 1;
fenTree = new int[size + 1];
}
public void add(int val, int indx)
{
indx++;
while(indx < this.size)
{
fenTree[indx] += val;
indx += (indx & (-indx)); //adding the last set bit
}
}
//upto which index you want prefix sum
public int getPrefSum(int indx)
{
int sum = 0;
indx++;
while(indx > 0)
{
sum += fenTree[indx];
indx -= (indx & (-indx)); //turning off the last set bit
}
return sum;
}
}
//-----------Disjoint set / Union-find-----------------------------------------------
static class DisjointSet
{
int parent[] = null;
int ranks[] = null;
DisjointSet(int len)
{
parent = new int[len];
ranks = new int[len];
for (int indx = 0; indx < parent.length; indx++)
{
parent[indx] = indx;
ranks[indx] = 0;
}
}
// Time complexity: O(Alpha(n)), Alpha(n) <= 4, therefore O(1) and auxiliary
// space: O(1) for recursion stack
public void union(int x, int y)
{
int xRep = find(x);
int yRep = find(y);
if (xRep == yRep)
return;
if (ranks[xRep] < ranks[yRep])
parent[xRep] = yRep;
else if (ranks[yRep] < ranks[xRep])
parent[yRep] = xRep;
else
{
parent[yRep] = xRep;
ranks[xRep]++;
}
}
// Time complexity: O(LogN) and auxiliary space: O(1) for recursion stack
public int find(int x)
{
if (parent[x] == x)
{
return x;
}
return parent[x] = find(parent[x]);
}
}
//-------GCD & LCM Section-----------------------------------------------------------------
private static int findGCDArr(int arr[], int n)
{
int result = arr[0];
for (int element: arr){
result = gcd(result, element);
if(result == 1)
{
return 1;
}
}
return result;
}
private static int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
public static BigInteger bigLcm(String a, String b)
{
// convert string 'a' and 'b' into BigInteger
BigInteger s = new BigInteger(a);
BigInteger s1 = new BigInteger(b);
// calculate multiplication of two bigintegers
BigInteger mul = s.multiply(s1);
// calculate gcd of two bigintegers
BigInteger gcd = s.gcd(s1);
// calculate lcm using formula: lcm * gcd = x * y
BigInteger lcm = mul.divide(gcd);
BigInteger lc = lcm.divide(s);
return lc;
}
private static int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
static List<Integer> findFactors(int n)
{
List<Integer> res = new ArrayList<>();
// Note that this loop runs till square root
for (int i=1; i<=Math.sqrt(n); i++)
{
if (n%i==0)
{
// If divisors are equal, add only one
if (n/i == i)
res.add(i);
else // Otherwise add both
res.add(i);
res.add(n/i);
}
}
return res;
}
//-----------------------------------------------------------------------------------------
//--------------------------binary exponentiation or power with modulo m-------------------
private static long binPow(int a, int b, int m){
if(b==0){
return a%m;
}
if(b % 2 == 0){
long pw = binPow(a, b/2, m);
return (1l * pw * pw % m);
}else{
long pw = binPow(a, (b-1)/2, m);
return 1l * pw * pw * a % m;
}
}
private static long mulInvMod(int x, int m){
return binPow(x, m-2, m);
}
//*****************************************************************************************
//--------------------------------Template ends--------------------------------------------
public static void main(String[] args) {
FastReader reader = new FastReader();
int t = reader.nextInt();
for(int tt = 1; tt<=t; tt++){
long n = reader.nextLong();
long sum = reader.nextLong();
// double nSq = Math.pow(n, 2);
// double cnt = Math.floor(sum/nSq);
// System.out.println(String.format("%.0f", cnt));
System.out.println(sum/(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 8 | 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< 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 | 6ad6c6e8aebb2b3a3a47886e9e95fe83 | 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 < 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.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
FastScanner fs = new FastScanner();
int t = fs.nextInt();
while (t-- != 0) {
long n = fs.nextLong(), s = fs.nextLong();
out.println((s / (n * n)));
}
out.flush();
out.close();
}
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
// 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());
}
long[] readArrayL(int n) {
long a[]=new long[n];
for(int i=0;i<n;i++) a[i]=nextLong();
return a;
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
} | Java | ["4\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 8 | 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< 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 | a96a01e97942b8fca339f8556b70e970 | 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 < 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.*;
import java.lang.*;
public class Main {
public static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
public static class InputReader {
StringTokenizer stringToken;
BufferedReader in;
public InputReader() {
stringToken = null;
in = new BufferedReader(new InputStreamReader(System.in));
}
public String next() throws IOException {
if (stringToken == null || !stringToken.hasMoreTokens()) {
stringToken = new StringTokenizer(in.readLine());
}
return stringToken.nextToken();
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
}
public static void main(String[] args) throws IOException {
InputReader in = new InputReader();
long t = in.nextLong();
while (t-- != 0) {
long n = in.nextLong(), s = in.nextLong();
long val = n * n - (n - 1);
if (s <= (n + 1) * (n - 1)) {
out.println(0);
} else {
out.println(((s - (n + 1) * (n - 1) + val - 1) / val));
}
}
out.flush();
out.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 8 | 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< 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 | 482dc602de9e66e3023a760821fb6b60 | 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 < 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;
/**
*
* @author Arunas
*/
public class NewMain {
/**
* @param args the command line arguments
* @return
*/
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int c = sc.nextInt();
for(int i = 0; i < c; i++){
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 8 | 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< 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 | d2b6d2c7a171ebddd42cf80220670c42 | 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 < 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 Solution{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
long[] ans=new long[t];
for(int i=0;i<t;i++){
long n=sc.nextLong();
long s=sc.nextLong();
ans[i]=(s/n)/n;
}
for(int i=0;i<t;i++){
System.out.println(ans[i]);
}
}
} | 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 8 | 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< 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 | f5ce7235710840c6ff5b80dacf74b01c | 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 < 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 Scanner sc = new Scanner(System.in);
public static void reverse(int[] arr, int l, int r) {
int d = (r - l + 1) / 2;
for (int i = 0; i < d; i++) {
int t = arr[l + i];
arr[l + i] = arr[r - i];
arr[r - i] = t;
}
}
public static void main(String[] args) {
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) {
solve();
}
}
static void solve() {
long n = sc.nextLong();
long s = sc.nextLong();
// int count = 0;
long answer = (s / (n * n));
// while (sq >= s) {
// count++;
// s -= sq;
// }
System.out.println(answer);
}
}
| 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 8 | 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< 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 | 9585f0e366ffdeb69a77933ebfe2e93c | 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 < 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.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.concurrent.atomic.LongAccumulator;
import javax.management.openmbean.ArrayType;
public class Main {
static PrintWriter out;
static int MOD = 1000000007;
static FastReader scan;
/*-------- I/O usaing short named function ---------*/
public static String ns() {
return scan.next();
}
public static int ni() {
return scan.nextInt();
}
public static long nl() {
return scan.nextLong();
}
public static double nd() {
return scan.nextDouble();
}
public static String nln() {
return scan.nextLine();
}
public static void p(Object o) {
out.print(o);
}
public static void ps(Object o) {
out.print(o + " ");
}
public static void pn(Object o) {
out.println(o);
}
/*-------- for output of an array ---------------------*/
static void iPA(int arr[]) {
StringBuilder output = new StringBuilder();
for (int i = 0; i < arr.length; i++) output.append(arr[i] + " ");
out.println(output);
}
static void lPA(long arr[]) {
StringBuilder output = new StringBuilder();
for (int i = 0; i < arr.length; i++) output.append(arr[i] + " ");
out.println(output);
}
static void sPA(String arr[]) {
StringBuilder output = new StringBuilder();
for (int i = 0; i < arr.length; i++) output.append(arr[i] + " ");
out.println(output);
}
static void dPA(double arr[]) {
StringBuilder output = new StringBuilder();
for (int i = 0; i < arr.length; i++) output.append(arr[i] + " ");
out.println(output);
}
/*-------------- for input in an array ---------------------*/
static void iIA(int arr[]) {
for (int i = 0; i < arr.length; i++) arr[i] = ni();
}
static void lIA(long arr[]) {
for (int i = 0; i < arr.length; i++) arr[i] = nl();
}
static void sIA(String arr[]) {
for (int i = 0; i < arr.length; i++) arr[i] = ns();
}
static void dIA(double arr[]) {
for (int i = 0; i < arr.length; i++) arr[i] = nd();
}
/*------------ for taking input faster ----------------*/
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;
}
}
// Method to check if x is power of 2
static boolean isPowerOfTwo(int x) {
return x != 0 && ((x & (x - 1)) == 0);
}
//Method to return lcm of two numbers
static int gcd(int a, int b) {
return a == 0 ? b : gcd(b % a, a);
}
//Method to count digit of a number
static int countDigit(long n) {
return (int) Math.floor(Math.log10(n) + 1);
}
//Method for sorting
static void sort(int[] a) {
ArrayList<Integer> l = new ArrayList<>();
for (int i : a) l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++) a[i] = l.get(i);
}
//Method for checking if a number is prime or not
static boolean isPrime(int n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (
n % i == 0 || n % (i + 2) == 0
) return false;
return true;
}
public static void reverse(int a[], int n) {
int i, k, t;
for (i = 0; i < n / 2; i++) {
t = a[i];
a[i] = a[n - i - 1];
a[n - i - 1] = t;
}
// printing the reversed array
System.out.println("Reversed array is: \n");
for (k = 0; k < n; k++) {
System.out.println(a[k]);
}
}
public static int binarysearch(int arr[], int left, int right, int num) {
int idx = 0;
while (left <= right) {
int mid = (left + right) / 2;
if (arr[mid] >= num) {
idx = mid;
// if(arr[mid]==num)break;
right = mid - 1;
} else {
left = mid + 1;
}
}
return idx;
}
public static int mod = 1000000007;
public static int[] rank;
public static void main(String[] args) throws java.lang.Exception {
OutputStream outputStream = System.out;
out = new PrintWriter(outputStream);
scan = new FastReader();
int T = ni();
while (T-- > 0) {
long n = nl();
long s=nl();
long sq=n*n;
long ans=0;
System.out.println(s/sq);
}
out.flush();
out.close();
}
public static long power(int a, long b) {
long ans = 1;
while (b > 0) {
if (b % 2 == 1) {
ans = (ans * a) % mod;
}
a = (a * a) % mod;
b /= 2;
}
return ans;
}
public static class pair implements Comparable<pair> {
int x;
int y;
pair(int x, int y) {
this.x = x;
this.y = y;
}
public int compareTo(pair o) {
if (this.x == o.x) {
return this.y - o.y;
} else {
return this.x - o.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 8 | 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< 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 | 8e7923bd18173522385ecc776f57ff55 | 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 < 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;
t = sc.nextInt();
while(t>0){
long n = sc.nextLong();
long s = sc.nextLong();
long count = (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 8 | 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< 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 | 2d48a23ebd7b3fd1099182f22034df94 | 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 < 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.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
public class CodeforcesQuestions {
public static void main(String[] args) {
Scanner s1=new Scanner(System.in);
int t=s1.nextInt();
while(t-->0)
{
long n=s1.nextLong();
long s=s1.nextLong();
if(n*n>s)
System.out.println("0");
else
{
long x=(s/(n*n));
System.out.println(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 8 | 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< 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 | 48650550cc5e7b8f0f4dcf0b9ba1864c | 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 < 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 {
static long solve (long n, long s) {
return (s/(n*n));
}
public static void main(String[]p) {
Scanner scan=new Scanner(System.in);
long t = scan.nextInt ();
int i;
for ( i = 0; i < t; i ++) {
long n = scan.nextLong ();
long s = scan.nextLong ();
long answer = solve(n,s);
System.out.println(answer);
}
}
} | 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 8 | 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< 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 | 320875080d6e56544cd51c825533b7d3 | 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 < 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[]p) {
Scanner scan=new Scanner(System.in);
long t = scan.nextLong ();
int i;
for ( i = 0; i < t; i ++) {
long n = scan.nextLong ();
long s = scan.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 8 | 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< 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 | 681a56f215d4c343208ee88de1999a1f | 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 < 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.awt.*;
import java.util.*;
import java.io.*;
public class Codeforces {
static FScanner sc = new FScanner();
static PrintWriter out = new PrintWriter(System.out);
static final Random random = new Random();
static long mod = 1000000007L;
static HashMap<String, Integer> map = new HashMap<>();
static boolean[] sieve = new boolean[1000000];
static double[] fib = new double[1000000];
public static void main(String args[]) throws IOException {
int T = sc.nextInt();
while (T-- > 0) {
long n=sc.nextLong();
long s=sc.nextLong();
long nn=n*n;
out.println((int)(s/(nn)));
}
out.close();
}
// TemplateCode
static void fib() {
fib[0] = 0;
fib[1] = 1;
for (int i = 2; i < fib.length; i++)
fib[i] = fib[i - 1] + fib[i - 2];
}
static void primeSieve() {
for (int i = 0; i < sieve.length; i++)
sieve[i] = true;
for (int i = 2; i * i <= sieve.length; i++) {
if (sieve[i]) {
for (int j = i * i; j < sieve.length; j += i) {
sieve[j] = false;
}
}
}
}
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 a;
return b;
}
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 FScanner {
BufferedReader br;
StringTokenizer st;
public FScanner() {
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 8 | 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< 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 | 041095c354662c1f4271573b6fd54ce4 | 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 < 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 | /*input
4
7 0
1 1
2 12
3 12
*/
import java.util.*;
import java.io.*;
public class SquareCounting {
public static void main(String[] args) {
FastReader reader = new FastReader();
int t = reader.nextInt();
while(t-- > 0){
long n = reader.nextLong();
long sum = reader.nextLong();
long nsq = n * n;
long res = sum != 0 ? sum / nsq : 0;
System.out.println(res);
}
}
}
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 8 | 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< 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 | 8c3fd7d5d9dfaacedf5bec37d98f185e | 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 < 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 | /*input
4
7 0
1 1
2 12
3 12
*/
import java.util.*;
import java.io.*;
public class SquareCounting {
public static void main(String[] args) {
FastReader reader = new FastReader();
int t = reader.nextInt();
while(t-- > 0){
long n = reader.nextLong();
long sum = reader.nextLong();
long nsq = n * n;
long res = sum != 0 ? sum / nsq : 0;
System.out.println(res);
}
}
}
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 8 | 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< 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 | c390bfbccab0cc7552bf8e34bc0e506e | 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 < 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();
System.out.println(1l*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 8 | 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< 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 | 25efaacfcb43f501a163d101cfc616e1 | 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 < 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 Stc {
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int n = scan.nextInt();
while (n-- > 0)
A();
}
static void A(){
long n = scan.nextLong();
long s = scan.nextLong();
System.out.println((long)(s/(n*n)) );
// System.out.println(list);
}
} | 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 8 | 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< 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 | d23b982fb301efaf0df7ac7e1001ad10 | 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 < 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 | //package extra;
import java.util.*;
import java.io.*;
public class codeForces {
public static void main(String[] args) {
FastReader in = new FastReader();
int t = in.nextInt();
while(t-->0) {
int n = in.nextInt();
long s = in.nextLong();
long ans = (long)n*(long)n;
// System.out.println(ans);
if (ans>s){
System.out.println(0);
}
else {
System.out.println(s/ans);
}
}
}
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
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;
}
}
static boolean isPrime(int n)
{
// Check if number is less than
// equal to 1
if (n <= 1)
return false;
// Check if number is 2
else if (n == 2)
return true;
// Check if n is a multiple of 2
else if (n % 2 == 0)
return false;
// If not, then just check the odds
for (int i = 3; i <= Math.sqrt(n); i += 2)
{
if (n % i == 0)
return false;
}
return true;
}
static int getSum(int n)
{
int sum = 0;
while (n != 0)
{
sum = sum + n % 10;
n = n/10;
}
return sum;
}
static long gcd(Long a, long b)
{
// Everything divides 0
if (a == 0)
return b;
if (b == 0)
return a;
// base case
if (a == b)
return a;
// a is greater
if (a > b)
return gcd(a-b, b);
return gcd(a, b-a);
}
static void swap(int[] arr, int i, int j)
{
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
static int countDigit(long n)
{
return (int)Math.floor(Math.log10(n) + 1);
}
static long fastpower(long a,long b,int n ) {
long res =1;
while(b>0) {
if((b&1)!=0) {
res = (res* a % n)%n;
}
a = (a % n*a % n) % n;
b = b >> 1;
}
return res;
}
static int catalan(int n)
{
int res = 0;
// Base case
if (n <= 1)
{
return 1;
}
for (int i = 0; i < n; i++)
{
res += catalan(i)
* catalan(n - i - 1);
}
return res;
}
static int mod(int a, int m)
{
return (a%m + m) % m;
}
} class Pair{
int first;
int second;
public Pair(int first, int second) {
this.first=first;
this.second=second;
}
} | 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 8 | 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< 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 | 6ad93fc6ece08f2e777263c00caa2029 | 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 < 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 CodeForces{
public static void main(String[] args) throws FileNotFoundException {
FastScanner fs = new FastScanner();
int t = fs.nextInt();
while(t-- > 0) {
long n = fs.nextLong();
long s = fs.nextLong();
System.out.println(s/(n*n));
}
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long[] readArrayLong(int n) {
long[] a=new long[n];
for(int i = 0; i < n; i++) a[i]=nextLong();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
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 8 | 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< 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 | 5def2634d8b7a96fb70d08bf2d9c9795 | 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 < 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.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class A_Square_Counting {
static Scanner in = new Scanner();
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
static int testCases;
static BigInteger n;
static BigInteger s;
static StringBuilder ans = new StringBuilder();
static void solve() {
if (s.longValue() == 0) {
//out.println(0);
//out.flush();
ans.append(0).append("\n");
return;
}
BigInteger highest_value = n.pow(2);
BigInteger ans1 = s.divide(highest_value);
ans.append(ans1.toString()).append("\n");
}
public static void main(String[] priya) throws IOException {
testCases = in.nextInt();
for (int t = 0; t < testCases; ++t) {
n = new BigInteger(in.next());
s = new BigInteger(in.next());
solve();
}
out.print(ans.toString());
out.flush();
in.close();
}
static String sum(String a, String b) {
StringBuilder ans1 = new StringBuilder();
int n1 = a.length(), m = b.length();
if (n1 > m) {
String t = a;
a = b;
b = t;
}
n1 = a.length();
m = b.length();
StringBuilder str1 = new StringBuilder(a).reverse();
StringBuilder str2 = new StringBuilder(b).reverse();
char first[] = str1.toString().toCharArray();
char second[] = str2.toString().toCharArray();
int carry = 0;
for (int i = 0; i < n1; i++) {
int sum = (first[i] - '0') + (second[i] - '0') + carry;
ans1.append(sum % 10);
carry = sum / 10;
}
for (int i = n1; i < m; i++) {
int sum = (second[i] - '0') + carry;
ans1.append(sum % 10);
sum /= 10;
}
if (carry > 0) {
ans1.append(carry);
}
ans1.reverse();
return ans1.toString();
}
static String mul(String num1, String num2) {
int len1 = num1.length();
int len2 = num2.length();
if (len1 == 0 || len2 == 0) {
return "0";
}
int result[] = new int[len1 + len2];
int i_n1 = 0;
int i_n2 = 0;
for (int i = len1 - 1; i >= 0; i--) {
int carry = 0;
int n1 = num1.charAt(i) - '0';
i_n2 = 0;
for (int j = len2 - 1; j >= 0; j--) {
int n2 = num2.charAt(j) - '0';
int sum = n1 * n2 + result[i_n1 + i_n2] + carry;
carry = sum / 10;
result[i_n1 + i_n2] = sum % 10;
i_n2++;
}
if (carry > 0) {
result[i_n1 + i_n2] += carry;
}
i_n1++;
}
int i = result.length - 1;
while (i >= 0 && result[i] == 0) {
i--;
}
if (i == -1) {
return "0";
}
String s1 = "";
while (i >= 0) {
s1 += (result[i--]);
}
return s1;
}
static int multiply(int x, int res[], int res_size) {
int carry = 0;
for (int i = 0; i < res_size; i++) {
int prod = res[i] * x + carry;
res[i] = prod % 10;
carry = prod / 10;
}
while (carry > 0) {
res[res_size] = carry % 10;
carry = carry / 10;
res_size++;
}
return res_size;
}
static long power(int x, int n) {
int MAX = 100000;
if (n == 0) {
return 1;
}
int res[] = new int[MAX];
int res_size = 0;
int temp = x;
while (temp != 0) {
res[res_size++] = temp % 10;
temp = temp / 10;
}
for (int i = 2; i <= n; i++) {
res_size = multiply(x, res, res_size);
}
StringBuilder sb = new StringBuilder();
for (int i = res_size - 1; i >= 0; i--) {
sb.append(res[i]);
}
return Long.parseLong(sb.toString());
}
static class Node<T> {
T data;
Node<T> next;
public Node() {
this.next = null;
}
public Node(T data) {
this.data = data;
this.next = null;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public Node<T> getNext() {
return next;
}
public void setNext(Node<T> next) {
this.next = next;
}
@Override
public String toString() {
return this.getData().toString() + " ";
}
}
static class ArrayList<T> {
Node<T> head, tail;
int len;
public ArrayList() {
this.head = null;
this.tail = null;
this.len = 0;
}
int size() {
return len;
}
boolean isEmpty() {
return len == 0;
}
int indexOf(T data) {
if (isEmpty()) {
throw new ArrayIndexOutOfBoundsException();
}
Node<T> temp = head;
int index = 0, i = 0;
while (temp != null) {
if (temp.getData() == data) {
index = i;
}
i++;
temp = temp.getNext();
}
return index;
}
void add(T data) {
Node<T> newNode = new Node<>(data);
if (isEmpty()) {
head = newNode;
tail = newNode;
len++;
} else {
tail.setNext(newNode);
tail = newNode;
len++;
}
}
void see() {
if (isEmpty()) {
throw new ArrayIndexOutOfBoundsException();
}
Node<T> temp = head;
while (temp != null) {
out.print(temp.getData().toString() + " ");
out.flush();
temp = temp.getNext();
}
out.println();
out.flush();
}
void inserFirst(T data) {
Node<T> newNode = new Node<>(data);
Node<T> temp = head;
if (isEmpty()) {
head = newNode;
tail = newNode;
len++;
} else {
newNode.setNext(temp);
head = newNode;
len++;
}
}
T get(int index) {
if (isEmpty() || index >= len) {
throw new ArrayIndexOutOfBoundsException();
}
Node<T> temp = head;
if (index == 0) {
return temp.getData();
}
int i = 0;
T data = null;
while (temp != null) {
if (i == index) {
data = temp.getData();
}
i++;
temp = temp.getNext();
}
return data;
}
void addAt(T data, int index) {
if (index >= len) {
throw new ArrayIndexOutOfBoundsException();
}
Node<T> newNode = new Node<>(data);
int i = 0;
Node<T> temp = head;
while (temp.next != null) {
if (i == index) {
newNode.setNext(temp.next);
temp.next = newNode;
}
i++;
temp = temp.getNext();
}
// temp.setNext(temp);
len++;
}
void popFront() {
if (isEmpty()) {
throw new ArrayIndexOutOfBoundsException();
}
if (head == tail) {
head = null;
tail = null;
} else {
head = head.getNext();
}
len--;
}
void removeAt(int index) {
if (index >= len) {
throw new ArrayIndexOutOfBoundsException();
}
if (index == 0) {
this.popFront();
return;
}
Node<T> temp = head;
int i = 0;
Node<T> n = new Node<>();
while (temp != null) {
if (i == index) {
n.next = temp.next;
temp.next = n;
break;
}
i++;
n = temp;
temp = temp.getNext();
}
tail = n;
--len;
}
void clearAll() {
this.head = null;
this.tail = null;
}
}
static long gcd(long a, long b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
static void merge(long a[], int left, int right, int mid) {
int n1 = mid - left + 1, n2 = right - mid;
long L[] = new long[n1];
long R[] = new long[n2];
for (int i = 0; i < n1; i++) {
L[i] = a[left + i];
}
for (int i = 0; i < n2; i++) {
R[i] = a[mid + 1 + i];
}
int i = 0, j = 0, k1 = left;
while (i < n1 && j < n2) {
if (L[i] <= R[j]) {
a[k1] = L[i];
i++;
} else {
a[k1] = R[j];
j++;
}
k1++;
}
while (i < n1) {
a[k1] = L[i];
i++;
k1++;
}
while (j < n2) {
a[k1] = R[j];
j++;
k1++;
}
}
static void sort(long a[], int left, int right) {
if (left >= right) {
return;
}
int mid = (left + right) / 2;
sort(a, left, mid);
sort(a, mid + 1, right);
merge(a, left, right, mid);
}
static class Node1<T> {
T data;
Node1 next;
public Node1(T data) {
this.data = data;
this.next = null;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public Node1 getNext() {
return next;
}
public void setNext(Node1 next) {
this.next = next;
}
}
static class Stack<T> {
int len;
Node1<T> node;
public Stack() {
len = 0;
node = null;
}
boolean isEmpty() {
return len == 0;
}
int size() {
return len;
}
void push(T data) {
Node1<T> temp = new Node1<>(data);
temp.setNext(this.node);
node = temp;
len++;
}
T top() {
if (isEmpty()) {
throw new ArrayIndexOutOfBoundsException();
}
return this.node.getData();
}
T pop() {
if (isEmpty()) {
throw new ArrayIndexOutOfBoundsException();
}
T data = this.node.getData();
this.node = this.node.getNext();
len--;
return data;
}
}
static class Scanner {
BufferedReader in;
StringTokenizer st;
public Scanner() {
in = new BufferedReader(new InputStreamReader(System.in));
}
String next() throws IOException {
while (st == null || !st.hasMoreElements()) {
st = new StringTokenizer(in.readLine());
}
return st.nextToken();
}
int nextInt() throws IOException {
return Integer.parseInt(next());
}
long nextLong() throws IOException {
return Long.parseLong(next());
}
String nextLine() throws IOException {
return in.readLine();
}
char nextChar() throws IOException {
return next().charAt(0);
}
double nextDouble() throws IOException {
return Double.parseDouble(next());
}
float nextFloat() throws IOException {
return Float.parseFloat(next());
}
boolean nextBoolean() throws IOException {
return Boolean.parseBoolean(next());
}
void close() throws IOException {
in.close();
}
}
}
/*
4
7 0
1 1
2 12
3 12
*/
| 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 8 | 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< 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 | 45c2286f960ba1c317fbb382c8d26478 | 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 < 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 A_Square_Counting
{
static int M = 1_000_000_007;
static final PrintWriter out =new PrintWriter(System.out);
static final FastReader fs = new FastReader();
static boolean prime[];
public static void main (String[] args) throws java.lang.Exception
{
int t= fs.nextInt();
for(int i=0;i<t;i++)
{
long n=fs.nextLong();
long s=fs.nextLong();
long x=(long)((double)(s-n*n+1)/(double)(n*n-n+1));
if(x<0){
out.println(0);
continue;
}
if(s-n*n*x<=(n+1-x)*(n-1)){
out.println(x);
}else{
out.println(x+1);
}
}
out.flush();
}
public static long power(long x, long y)
{
long temp;
if (y == 0)
return 1;
temp = power(x, y / 2);
if (y % 2 == 0)
return modMult(temp,temp);
else {
if (y > 0)
return modMult(x,modMult(temp,temp));
else
return (modMult(temp,temp)) / x;
}
}
static void sieveOfEratosthenes(int n)
{
prime = new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
prime[0]=false;
if(1<=n)
prime[1]=false;
for (int p = 2; p * p <= n; p++)
{
if (prime[p] == true)
{
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
}
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 [] arrayIn(int n) throws IOException
{
int arr[] = new int[n];
for(int i=0; i<n; i++)
{
arr[i] = nextInt();
}
return arr;
}
}
public static class Pairs implements Comparable<Pairs>
{
int value,index;
Pairs(int value, int index)
{
this.value = value;
this.index = index;
}
public int compareTo(Pairs p)
{
return Integer.compare(this.value, p.value);
}
}
static final Random random = new Random();
static void ruffleSort(int arr[])
{
int n = arr.length;
for(int i=0; i<n; i++)
{
int j = random.nextInt(n),temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
Arrays.sort(arr);
}
static long nCk(int n, int k) {
return (modMult(fact(n),fastexp(modMult(fact(n-k),fact(k)),M-2)));
}
static long fact (long n) {
long fact =1;
for(int i=1; i<=n; i++) {
fact = modMult(fact,i);
}
return fact%M;
}
static long modMult(long a,long b) {
return a*b%M;
}
static long fastexp(long x, int y){
if(y==1) return x;
long ans = fastexp(x,y/2);
if(y%2 == 0) return modMult(ans,ans);
else return modMult(ans,modMult(ans,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 8 | 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< 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 | fb456427a534bffaed82c6b0f5090b8b | 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 < 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 input = new Scanner(System.in);
StringBuilder output = new StringBuilder();
int t = input.nextInt();
while(t > 0) {
int n = input.nextInt();
long s = input.nextLong();
long temp = (long)n*(long)n;
output.append((s/temp));
output.append("\n");
--t;
}
System.out.print(output);
}
} | 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 8 | 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< 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 | a333df037b29c2025729c3eb4277cf3e | 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 < 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 div_2_774_a {
public static void main(String args[]){
FScanner in = new FScanner();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
while(t-->0) {
int n=in.nextInt();
long s=in.nextLong();
if(s==0)
out.println(0);
else
{
long ans=(long)n*n;
out.println((long)(s/ans));
}
}
out.close();
}
static class FScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer sb = new StringTokenizer("");
String next(){
while(!sb.hasMoreTokens()){
try{
sb = new StringTokenizer(br.readLine());
} catch(IOException e){ }
}
return sb.nextToken();
}
String nextLine(){
try{ return br.readLine(); }
catch(IOException e) { } return "";
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
int[] readArray(int n) {
int a[] = new int[n];
for(int i=0;i<n;i++) a[i] = nextInt();
return a;
}
float nextFloat(){
return Float.parseFloat(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
}
}
| Java | ["4\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 8 | 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< 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 | dda08bf717df4f76dc2333095845ee62 | 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 < 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 cc {
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 pow=n*n;
long ans=s/pow;
System.out.println(ans);
}
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 8 | 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< 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 | 55285930cd23090aaf735432b8871a40 | 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 < 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.*;
import static java.lang.Math.*;
public class A {
static PrintWriter pw = new PrintWriter(System.out);
static FastReader fr = new FastReader();
public static void main(String[] args) {
int t = fr.nextInt();
while (t-- > 0) {
solve();
}
pw.flush();
}
static void solve() {
long n = fr.nextLong();
long s = fr.nextLong();
long ans = s / (n*n);
pw.println(ans);
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
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 8 | 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< 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 | 912dc82e929ae12118f997bd7d9e2515 | 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 < 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.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class R774A {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int t = Integer.parseInt(st.nextToken());
while (t-- > 0) {
st = new StringTokenizer(br.readLine());
long n = Long.parseLong(st.nextToken());
long k = Long.parseLong(st.nextToken());
solve(n, k);
}
}
private static void solve(long n, long k) {
System.out.println(k / (n*n));
}
}
/*
4 4 4 16 16
1
4 32
*/
| 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 8 | 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< 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 | a7c83b3c08bcebc4ad5e1c4656f60dd4 | 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 < 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.awt.*;
import java.io.IOException;
import java.util.*;
import java.util.List;
public class test {
public static void main(String[] args) {
Scanner inputul = new Scanner(System.in);
long t = inputul.nextInt();
for (int i = 0; i < t; i++) {
long n = inputul.nextLong();
long s = inputul.nextLong();
long res = s/(n*n);
System.out.println(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 8 | 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< 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 | 4a9fe0df4f4123cc7e06c90bab906edf | 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 < 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 sc=new Scanner(System.in);
int t=sc.nextInt();
while (t-->0){
long n=sc.nextLong();
long s=sc.nextLong();
long r=n*n;
long rem=s/r;
System.out.println(rem);
}
}
}
| 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 8 | 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< 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 | badcc3e8b87798707f7ce7bffcbe5b9b | 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 < 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 A {
public static void main(String[] args) throws IOException {
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 8 | 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< 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 | 24a618db3ce3a562c5636761c6f0a294 | 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 < 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.Arrays;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int t=in.nextInt();
for (int i = 0; i < t; i++) {
BigInteger small=new BigInteger(in.next());
small=small.multiply(small);
BigInteger big=new BigInteger(in.next());
System.out.println(big.divide(small));
}}
}
| 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 8 | 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< 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 | 5d49e8d294edde6d949528709a0b3102 | 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 < 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 A {
public static void main(String args[]) throws IOException {
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int t = nextInt();
while (t-->0) {
long n = nextLong(), s = nextLong();
out.println(s/(long)Math.pow(n, 2));
}
out.close();
}
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st = new StringTokenizer("");
static String next() throws IOException {
while (!st.hasMoreElements()) {st = new StringTokenizer(br.readLine());}
return st.nextToken();
}
static int nextInt() throws IOException {return Integer.parseInt(next());}
static long nextLong() throws IOException {return Long.parseLong(next());}
static double nextDouble() throws IOException {return Double.parseDouble(next());}
static 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 8 | 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< 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 | 86592716553e13a73cbe4642c1f3b73d | 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 < 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 ASquareCounting {
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 nSquare = n*n;
System.out.println(s/nSquare);
}
}
}
| 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 8 | 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< 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 | d2e696448ceee74b6b144f41f0da8c4b | 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 < 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 javax.management.Query;
import java.io.*;
public class Main {
// static int n,k;
//// static String t,s;
// static long[]memo;
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
long s=sc.nextLong();
long ans=s/(1l*n*n);
pw.println(ans);
}
pw.close();
}
// public static long dp(int idx) {
// if (idx >= n)
// return Long.MAX_VALUE/2;
// return Math.min(dp(idx+1),memo[idx]+dp(idx+k));
// }
// if(num==k)
// return dp(0,idx+1);
// if(memo[num][idx]!=-1)
// return memo[num][idx];
// long ret=0;
// if(num==0) {
// if(s.charAt(idx)=='a')
// ret= dp(1,idx+1);
// else if(s.charAt(idx)=='?') {
// ret=Math.max(1+dp(1,idx+1),dp(0,idx+1) );
// }
// }
// else {
// if(num%2==0) {
// if(s.charAt(idx)=='a')
// ret=dp(num+1,idx+1);
// else if(s.charAt(idx)=='?')
// ret=Math.max(1+dp(num+1,idx+1),dp(0,idx+1));
// }
// else {
// if(s.charAt(idx)=='b')
// ret=dp(num+1,idx+1);
// else if(s.charAt(idx)=='?')
// ret=Math.max(1+dp(num+1,idx+1),dp(0,idx+1));
// }
// }
// }
public static int maxmin(int[]a,int[]b) {
int[] res=new int[a.length];
for (int i = 0; i < b.length; i++) {
res[i]=Math.max(a[i], b[i]);
}
int min=Integer.MAX_VALUE;
for (int i = 0; i < res.length; i++) {
min=Math.min(min, res[i]);
}
return min;
}
public static int[] swap(int[] a, int x,int y) {
int [] t=new int [a.length];
for (int i = 0; i < t.length; i++) {
if(a[i]==x)
t[i]=y;
else if(a[i]==y)
t[i]=x;
else
t[i]=a[i];
}
return t;
}
public static boolean palind(String s) {
for (int i = 0; i < s.length()/2; i++) {
if(s.charAt(i)!=s.charAt(s.length()-i-1))
return false;
}
return true;
}
public static int max4(int a,int b, int c,int d) {
int [] s= {a,b,c,d};
Arrays.sort(s);
return s[3];
}
public static double logbase2(int k) {
return( (Math.log(k)+0.0)/Math.log(2));
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader r) {
br = new BufferedReader(r);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public long[] nextlongArray(int n) throws IOException {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public Long[] nextLongArray(int n) throws IOException {
Long[] a = new Long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public int[] nextIntArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public Integer[] nextIntegerArray(int n) throws IOException {
Integer[] a = new Integer[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public boolean ready() throws IOException {
return br.ready();
}
}
static class pair implements Comparable<pair> {
long x;
long y;
public pair(long x, long y) {
this.x = x;
this.y = y;
}
public String toString() {
return x + " " + y;
}
public boolean equals(Object o) {
if (o instanceof pair) {
pair p = (pair) o;
return p.x == x && p.y == y;
}
return false;
}
public int hashCode() {
return new Long(x).hashCode() * 31 + new Long(y).hashCode();
}
public int compareTo(pair other) {
if (this.x == other.x) {
return Long.compare(this.y, other.y);
}
return Long.compare(this.x, other.x);
}
}
static class tuble implements Comparable<tuble> {
int x;
int y;
int z;
public tuble(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public String toString() {
return x + " " + y + " " + z;
}
public int compareTo(tuble other) {
if (this.x == other.x) {
if (this.y == other.y) {
return this.z - other.z;
}
return this.y - other.y;
} else {
return this.x - other.x;
}
}
}
static long mod = 1000000007;
static Random rn = new Random();
static Scanner sc = new Scanner(System.in);
static PrintWriter pw = 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 8 | 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< 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 | 11c4ab6f15d55f994561b0826b1cefd9 | 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 < 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 Main {
//--------------------------INPUT READER---------------------------------//
static class fs {
public BufferedReader br;
StringTokenizer st = new StringTokenizer("");
public fs() { this(System.in); }
public fs(InputStream is) {
br = new BufferedReader(new InputStreamReader(is));
}
String next() {
while (!st.hasMoreTokens()) {
try { st = new StringTokenizer(br.readLine()); }
catch (IOException e) { e.printStackTrace(); }
}
return st.nextToken();
}
int ni() { return Integer.parseInt(next()); }
long nl() { return Long.parseLong(next()); }
double nd() { return Double.parseDouble(next()); }
String ns() { return next(); }
int[] na(long nn) {
int n = (int) nn;
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = ni();
return a;
}
long[] nal(long nn) {
int n = (int) nn;
long[] l = new long[n];
for(int i = 0; i < n; i++) l[i] = nl();
return l;
}
}
//-----------------------------------------------------------------------//
//---------------------------PRINTER-------------------------------------//
static class Printer {
static PrintWriter w;
public Printer() {this(System.out);}
public Printer(OutputStream os) {
w = new PrintWriter(os);
}
public void p(int i) {w.println(i);}
public void p(long l) {w.println(l);}
public void p(double d) {w.println(d);}
public void p(String s) { w.println(s);}
public void pr(int i) {w.print(i);}
public void pr(long l) {w.print(l);}
public void pr(double d) {w.print(d);}
public void pr(String s) { w.print(s);}
public void pl() {w.println();}
public void close() {w.close();}
}
//-----------------------------------------------------------------------//
//--------------------------VARIABLES------------------------------------//
static fs sc = new fs();
static OutputStream outputStream = System.out;
static Printer w = new Printer(outputStream);
static long lma = Long.MAX_VALUE, lmi = Long.MIN_VALUE;
static int ima = Integer.MAX_VALUE, imi = Integer.MIN_VALUE;
static long mod = 1000000007;
//-----------------------------------------------------------------------//
//--------------------------ADMIN_MODE-----------------------------------//
private static void ADMIN_MODE() throws IOException {
if (System.getProperty("ONLINE_JUDGE") == null) {
w = new Printer(new FileOutputStream("output.txt"));
sc = new fs(new FileInputStream("input.txt"));
}
}
//-----------------------------------------------------------------------//
//----------------------------START--------------------------------------//
public static void main(String[] args)
throws IOException {
ADMIN_MODE();
int t = sc.ni();while(t-->0)
solve();
w.close();
}
static void solve() throws IOException {
int n = sc.ni();
long sum = sc.nl();
long max = (n+1)*(n-1L);
long rem = sum-max;
if(rem <= 0) {
w.p(0);
return;
}
long q = rem/((long)n*n);
if(rem%((long) n*n)!=0) q++;
w.p(q);
}
} | 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 8 | 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< 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 | 6063e9ac21cbbe0d7bfaf3997f41d7dd | 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 < 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 Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args)
{
FastReader fs = new FastReader();
int t = fs.nextInt();
while(t-->0)
{
long n = fs.nextLong();
long s = fs.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 8 | 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< 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 | 9739e0346ce1df7a968568198e98e7a6 | 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 < 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.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) {
try(InputStream inputStream = System.in;){
InputReader in = new InputReader(inputStream);
int T = in.nextInt();
while(T-- > 0){
long n = in.nextLong();
long s = in.nextLong();
System.out.println(s/(n*n));
}
}catch(Exception e){
e.printStackTrace();
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next(){
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
}
} | 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 8 | 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< 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 | ba01791efbf20225e74c189a355b586e | 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 < 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.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) {
try(InputStream inputStream = System.in;Scanner sc = new Scanner(inputStream);){
InputReader in = new InputReader(inputStream);
int T = sc.nextInt();
while(T-- > 0){
long n = sc.nextLong();
long s = sc.nextLong();
System.out.println(s/(n*n));
}
}catch(Exception e){
e.printStackTrace();
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next(){
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
| 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 8 | 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< 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 | a1aecb2af6bf8b7188645910d2b1a5cd | 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 < 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) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int m = sc.nextInt();
while (m-- > 0) {
long n =sc.nextLong();
long s = sc.nextLong();
long num = n*n;
System.out.println(s/num);
}
}
}
}
| 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 8 | 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< 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 | 5ddcacab32042e000ef5fb9cd6c88932 | 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 < 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 A {
public static void main(String[] args) throws Exception{
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int TC = Integer.parseInt(br.readLine());
while(TC-- > 0){
StringTokenizer st = new StringTokenizer(br.readLine());
long N = Long.parseLong(st.nextToken());
long S = Long.parseLong(st.nextToken());
bw.write(S / (N * N) + "\n");
}
bw.flush();
bw.close();
}
/*
static long find(long N, long n, long s){
if(n == 0) return 0;
long pow = N * N;
if(calculed >= 0) return find(N, n - 1, calculed) + 1;
return 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 8 | 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< 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 | d74d3576c8f26616a3c6535841c3e3d8 | 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 < 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.lang.*;
import java.io.*;
import java.util.*;
public class My
{
public static void main(String[] args)
{
Scanner scn=new Scanner(System.in);
long t=scn.nextLong();
while(t-->0)
{
long a=scn.nextLong();
long b=scn.nextLong();
long ans=b/(a*a);
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 8 | 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< 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 | 1cd3a65328d5237355cb0aee3eb98cf3 | 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 < 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 A {
public static void main(String[] args) throws IOException {
// Scanner sc = new Scanner(new FileReader("input.in"));
// PrintWriter pw = new PrintWriter(new FileWriter(""));
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
// int t = 1;
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
long s = sc.nextLong();
pw.println(s/((long) n *n));
}
pw.close();
}
// -------------------------------------------------------Basics----------------------------------------------------
//-------------------------------------------------------- GRAPHS ----------------------------------------------------
static ArrayList<Integer> adj[];
static boolean vis[];
static void bfs (int node){
Queue<Integer> q= new LinkedList<>();
q.add(node);
vis[node]=true;
while(!q.isEmpty()){
int tmp= q.poll();
for(int i : adj[tmp]){
if(!vis[i]){
q.add(i);
vis[i]=true;
}
}
}
}
public static void dfs(int node ){
vis[node]=true;
for(int x: adj[node]){
if(!vis[x])
dfs(x);
}
}
//------------------------------------------------------ BINARYSEARCH ------------------------------------------------
// binary search // first occur // last occur
public static int binarySearch(long x, Long [] a){
int i =0;
int j = a.length-1;
int mid ;
while(i<=j){
mid = (i+j)/2;
if(a[mid]<=x){
i=mid+1;
}else{
j=mid-1;
}
}
return i;
}
// ------------------------------------------------------- MATH ----------------------------------------------------
private static int gcd(int a, int b) {
return (b == 0)? a : gcd(b, a % b);
}
private static long gcd(long a, long b) {
return (b == 0)? a : 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;
}
// ------------------------------------------------------ Objects --------------------------------------------------
static class Pair implements Comparable<Pair>{
long x ;
long y ;
Pair(long x , long y){
this.x=x;
this.y=y;
}
@Override
public int compareTo(Pair o) {
if(this.x==o.x)return 0;
if(this.x>o.x)return 1;
return -1;
}
@Override
public String toString() {
return x +" " + y ;
}
}
static class Tuple implements Comparable<Tuple>{
int x;
int y;
int z;
Tuple(int x, int y , int z){
this.x=x;
this.y=y;
this.z=z;
}
@Override
public int compareTo(Tuple o) {
if(this.x==o.x){
if(this.y==o.y)return this.z-o.z;
return this.y-o.y;
}
return this.x-o.x;
}
@Override
public String toString() {
return x +" " + y + " " + z ;
}
}
// -------------------------------------------------------Scanner---------------------------------------------------
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader r) {
br = new BufferedReader(r);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public long[] nextlongArray(int n) throws IOException {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public Long[] nextLongArray(int n) throws IOException {
Long[] a = new Long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public int[] nextIntArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public Integer[] nextIntegerArray(int n) throws IOException {
Integer[] a = new Integer[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public boolean ready() throws IOException {
return br.ready();
}
}
}
| Java | ["4\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 8 | 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< 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 | 7ccafcfd3c9299765e338666eb728ead | 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 < 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 8 | 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< 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 | ba01ab41f24e4332e6224203d2282d76 | 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 < 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 SqureCounting {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long t=sc.nextLong();
for(long 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 8 | 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< 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 | 5d2a6bd54304bec77e84d527b13a9266 | 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 < 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 | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main {
public static void main(String[] args) throws Exception {
Scanner scn = new Scanner(System.in);
long t = scn.nextInt();
for(long i = 0; i < t; i++){
long n = scn.nextInt();
long s = scn.nextLong();
long num = s / (n*n);
System.out.println(num);
}
}
} | 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 8 | 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< 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 | 6823eb72913b768676920ed4144a09e1 | 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 < 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) {
int count = 0;
Scanner scanner = new Scanner(System.in);
long t = scanner.nextInt();
long n = 0,s = 0;
for (int i = 0;i < t;i++) {
n = scanner.nextLong();
s = scanner.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 8 | 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< 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 | ac935d857b1ab3cbf634bd44f28f3833 | 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 < 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.*;
//import javafx.util.*;
public class Main
{
static FastReader in = new FastReader();
public static void main(String args[])throws IOException
{
/*
* star,rope,TPST
* BS,LST,MS,MQ
*/
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;
long count = s/square;
System.out.println(count);
}
}
static int i()
{
return in.nextInt();
}
static long l()
{
return in.nextLong();
}
static int[] input(int N){
int A[]=new int[N];
for(int i=0; i<N; i++)
{
A[i]=in.nextInt();
}
return A;
}
static long[] inputLong(int N) {
long A[]=new long[N];
for(int i=0; i<A.length; i++)A[i]=in.nextLong();
return A;
}
}
class Pair{
int x;
Character c;
Pair(int x, Character c){
this.x = x;
this.c = c;
}
}
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 8 | 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< 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 | ba2d9709e943ade7a90d9655447942a6 | 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 < 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.time.Year;
import java.util.*;
public class Temp {
static long t,n,s;
static List<Integer> list=new ArrayList<>();
static Scanner sc=new Scanner(System.in);
static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer in = new StreamTokenizer(bf);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
t=sc.nextInt();
while(t-->0) solve();
out.flush();
}
static void solve() throws IOException {
n=sc.nextLong();
s=sc.nextLong();
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 8 | 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< 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 | 31bec196ae9cfb62d26e8357123af7c3 | 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 < 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 Codeforces
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
long t=sc.nextLong();
while(t-->0)
{
Long n=sc.nextLong();
Long s=sc.nextLong();
Long num=s/(n*n);
System.out.println(num);
}
}
} | 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 8 | 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< 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 | 15909acc04c31a5c1725f2ca1938769c | 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 < 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 L3 {
public static void main(String[] args) throws Exception{
Scanner br = new Scanner(System.in);
int totalInputs = br.nextInt();
for(int i=0;i<totalInputs;i++){
Long n = Long.parseLong(br.next());
Long s = Long.parseLong(br.next());
Long sq = n*n;
int count = 0;
if(s >= sq)
count = (int)(s/sq);
System.out.println(count);
}
br.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 8 | 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< 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 | 452e660b53fdbb3dcbda3a61fcf3cbff | 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 < 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 x=n*n;
long c=s/x;
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 8 | 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< 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 | ac32df3aea184f5ed77231ff642f4b74 | 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 < 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 Codeforces774_1 {
public static void main(String[] args) {
Scanner input =new Scanner(System.in);
long t=input.nextInt();
for(long i=0;i<t;i++){
long n=input.nextLong();
Long s=input.nextLong();
Long x=n*n;
long y=((n)*(n+1)/2);
//System.out.println(y);
long count=s/x;
/*else if(x<=s) {
for (long j = 1; j <= n + 1; j++) {
//System.out.println(y + " " + x + " " + s + " " + ((x * j) + (n - j)));
if ((x * j) + (n - j) <= s) {
count++;
n1--;
}
if(count!=j){
break;
}
}
}*/
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 8 | 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< 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 | 859f8d8d43de152270042e797149f062 | 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 < 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 | //package com.competetive.div;
// Working program using Reader Class
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import static java.lang.System.out;
public class SquareCounting {
// public static void main(String[] args) throws IOException {
// Reader sc = new Reader();
// for(int test = sc.nextInt();test>0; test--) {
// BigInteger n = new BigInteger(String.valueOf(sc.nextInt()));
// BigInteger s = new BigInteger(String.valueOf(sc.nextInt()));
// BigInteger count = new BigInteger("0");
// BigInteger square = n.multiply(n);
// while(s.subtract(square).longValue() >= new BigInteger("0").longValue()) {
// s = s.subtract(square);
// count = count.add(new BigInteger("1"));
// if(s.subtract(square).longValue() < new BigInteger("0").longValue()) break;
// }
// out.println(count.longValue());
// }
// }
public static void main(String[] args) throws IOException {
Reader sc = new Reader();
StringBuilder stringBuilder = new StringBuilder();
for(long test = sc.nextInt();test>0; test--) {
long n = sc.nextLong();
long s = sc.nextLong();
long count = 0;
long square = n*n;
if ((s - square) >= 0) {
count = (int)(s / square);
}
stringBuilder.append(count).append("\n");
}
out.println(stringBuilder);
}
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();
}
}
}
| 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 8 | 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< 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 | 9c1f4b8cc3fed9d53815f22be5a49fc9 | 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 < 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 A1646 {
public static void main(String[] args) {
//Input
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
long[] ans = new long[t];
for (int i = 0; i < t; i++) {
long n = scanner.nextLong();
long s = scanner.nextLong();
ans[i] = s/(n*n);
}
scanner.close();
//Output
for (long i : ans) System.out.println(i);
}
} | 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 8 | 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< 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 | 642ef923ece605ba9c395a8040766568 | 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 < 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 tcs = sc.nextInt();
for(int tc=0; tc<tcs; tc++){
long n = sc.nextLong();
long s = sc.nextLong();
long pro = n*n;
long res = s/pro;
System.out.println(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 8 | 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< 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 | ff8d95bff7ab4b009a34438bddbfcc5a | 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 < 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 Contest {
public static void main(String[] args) {
sc();
}
private static void sc(){
Scanner scanner = new Scanner(System.in);
int caseNum = scanner.nextInt();
while(caseNum > 0){
long n, s;
n = scanner.nextLong();
s = scanner.nextLong();
long r = s / (n*n);
System.out.println(r);
caseNum--;
}
}
}
| 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 8 | 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< 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 | 4d1bc2635fef5ee3517295b4e28aaeb9 | 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 < 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 Solution {
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 8 | 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< 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 | 6b52d332f5cdd69691309d02dc9aa2b6 | 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 < 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/(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 8 | 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< 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 | ba00050511c0d851887f4a06b0d2b411 | 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 < 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.*;
// BEFORE 31ST MARCH 2022 !!
//MAX RATING EVER ACHIEVED-1622(LETS SEE WHEN WILL I GET TO CHANGE THIS)
////***************************************************************************
/* public class E_Gardener_and_Tree implements Runnable{
public static void main(String[] args) throws Exception {
new Thread(null, new E_Gardener_and_Tree(), "E_Gardener_and_Tree", 1<<28).start();
}
public void run(){
WRITE YOUR CODE HERE!!!!
JUST WRITE EVERYTHING HERE WHICH YOU WRITE IN MAIN!!!
}
}
*/
/////**************************************************************************
public class A_Square_Counting{
public static void main(String[] args) {
FastScanner s= new FastScanner();
//PrintWriter out=new PrintWriter(System.out);
//end of program
//out.println(answer);
//out.close();
StringBuilder res = new StringBuilder();
int t=s.nextInt();
int p=0;
while(p<t){
long n=s.nextLong();
long sum=s.nextLong();
long yo=n*n;
//int count=0;
long hh=sum/yo;
res.append(hh+" \n");
p++;
}
System.out.println(res);
}
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(String s) {
try {
br = new BufferedReader(new FileReader(s));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String nextToken() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(nextToken());
}
long nextLong() {
return Long.parseLong(nextToken());
}
double nextDouble() {
return Double.parseDouble(nextToken());
}
}
static long modpower(long x, long y, long p)
{
long res = 1; // Initialize result
x = x % p; // Update x if it is more than or
// equal to p
if (x == 0)
return 0; // In case x is divisible by p;
while (y > 0)
{
// If y is odd, multiply x with result
if ((y & 1) != 0)
res = (res * x) % p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
// SIMPLE POWER FUNCTION=>
static long power(long x, long y)
{
long res = 1; // Initialize result
while (y > 0)
{
// If y is odd, multiply x with result
if ((y & 1) != 0)
res = res * x;
// y must be even now
y = y >> 1; // y = y/2
x = x * x; // Change x to x^2
}
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 8 | 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< 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 | 422878e7522aa0745f79ade8fc839690 | 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 < 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 | /*
Rating: 1461
Date: 04-03-2022
Time: 21-06-30
Author: Kartik Papney
Linkedin: https://www.linkedin.com/in/kartik-papney-4951161a6/
Leetcode: https://leetcode.com/kartikpapney/
Codechef: https://www.codechef.com/users/kartikpapney
*/
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class A_Square_Counting {
public static boolean debug = false;
static void debug(String st) {
if(debug) p.writeln(st);
}
public static void s() {
long n = sc.nextLong();
long s = sc.nextLong();
p.writeln(s/(n*n));
}
public static void main(String[] args) {
int t = 1;
t = sc.nextInt();
while (t-- != 0) {
s();
}
p.print();
}
static final Integer MOD = (int) 1e9 + 7;
static final FastReader sc = new FastReader();
static final Print p = new Print();
static class Functions {
static void sort(int[] a) {
ArrayList<Integer> l = new ArrayList<>();
for (int i : a) l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++) a[i] = l.get(i);
}
static void sort(long[] a) {
ArrayList<Long> l = new ArrayList<>();
for (long i : a) l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++) a[i] = l.get(i);
}
static int max(int[] a) {
int max = Integer.MIN_VALUE;
for (int val : a) max = Math.max(val, max);
return max;
}
static int min(int[] a) {
int min = Integer.MAX_VALUE;
for (int val : a) min = Math.min(val, min);
return min;
}
static long min(long[] a) {
long min = Long.MAX_VALUE;
for (long val : a) min = Math.min(val, min);
return min;
}
static long max(long[] a) {
long max = Long.MIN_VALUE;
for (long val : a) max = Math.max(val, max);
return max;
}
static long sum(long[] a) {
long sum = 0;
for (long val : a) sum += val;
return sum;
}
static int sum(int[] a) {
int sum = 0;
for (int val : a) sum += val;
return sum;
}
public static long mod_add(long a, long b) {
return (a % MOD + b % MOD + MOD) % MOD;
}
public static long pow(long a, long b) {
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = mod_mul(res, a);
a = mod_mul(a, a);
b >>= 1;
}
return res;
}
public static long mod_mul(long a, long b) {
long res = 0;
a %= MOD;
while (b > 0) {
if ((b & 1) > 0) {
res = mod_add(res, a);
}
a = (2 * a) % MOD;
b >>= 1;
}
return res;
}
public static long gcd(long a, long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
public static long factorial(long n) {
long res = 1;
for (int i = 1; i <= n; i++) {
res = (i % MOD * res % MOD) % MOD;
}
return res;
}
public static int count(int[] arr, int x) {
int count = 0;
for (int val : arr) if (val == x) count++;
return count;
}
public static ArrayList<Integer> generatePrimes(int n) {
boolean[] primes = new boolean[n];
for (int i = 2; i < primes.length; i++) primes[i] = true;
for (int i = 2; i < primes.length; i++) {
if (primes[i]) {
for (int j = i * i; j < primes.length; j += i) {
primes[j] = false;
}
}
}
ArrayList<Integer> arr = new ArrayList<>();
for (int i = 0; i < primes.length; i++) {
if (primes[i]) arr.add(i);
}
return arr;
}
}
static class Print {
StringBuffer strb = new StringBuffer();
public void write(Object str) {
strb.append(str);
}
public void writes(Object str) {
char c = ' ';
strb.append(str).append(c);
}
public void writeln(Object str) {
char c = '\n';
strb.append(str).append(c);
}
public void writeln() {
char c = '\n';
strb.append(c);
}
public void yes() {
char c = '\n';
writeln("YES");
}
public void no() {
writeln("NO");
}
public void writes(int[] arr) {
for (int val : arr) {
write(val);
write(' ');
}
}
public void writes(long[] arr) {
for (long val : arr) {
write(val);
write(' ');
}
}
public void writeln(int[] arr) {
for (int val : arr) {
writeln(val);
}
}
public void print() {
System.out.print(strb);
}
public void println() {
System.out.println(strb);
}
}
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());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
long[] readLongArray(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++) a[i] = nextLong();
return a;
}
double[] readArrayDouble(int n) {
double[] a = new double[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
String nextLine() {
String str = new String();
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 8 | 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< 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 | 1460562f6c328ae4c052bade8908e4f8 | 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 < 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();
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 8 | 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< 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 | 0a20c186f9e69c7cedb9584d6a2662e8 | 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 < 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.math.BigInteger;
import java.util.*;
public class Test {
public static void main(String[] args) throws IOException {
Reader rd = new Reader();
int t = rd.nextInt();
while (t-- > 0) {
long n = rd.nextLong();
long sum = rd.nextLong();
long square = n * n;
System.out.println((sum / square));
}
rd.close();
}
/**
* method to print int value in console output
**/
private static void debug(int value) {
if (System.getProperty("ONLINE_JUDGE") == null) {
System.out.println("int value = " + value);
}
}
/**
* method to print int value in console output with a text message
**/
private static void debug(int value, String message) {
if (System.getProperty("ONLINE_JUDGE") == null) {
if (message.charAt(message.length() - 1) != ' ') message += " ";
System.out.println(message + "" + value);
}
}
/**
* method to print long value in console output
**/
private static void debug(long value) {
if (System.getProperty("ONLINE_JUDGE") == null) {
System.out.println("long value = " + value);
}
}
/**
* method to print long value in console output with a text message
**/
private static void debug(long value, String message) {
if (System.getProperty("ONLINE_JUDGE") == null) {
if (message.charAt(message.length() - 1) != ' ') message += " ";
System.out.println(message + "" + value);
}
}
/**
* method to print String value in console output
**/
private static void debug(String value) {
if (System.getProperty("ONLINE_JUDGE") == null) {
System.out.println("String value = " + value);
}
}
/**
* method to print String value in console output with a text message
**/
private static void debug(String value, String message) {
if (System.getProperty("ONLINE_JUDGE") == null) {
if (message.charAt(message.length() - 1) != ' ') message += " ";
System.out.println(message + "" + value);
}
}
/**
* method to print character value in console output
**/
private static void debug(char value) {
if (System.getProperty("ONLINE_JUDGE") == null) {
System.out.println("Character value = " + value);
}
}
/**
* method to print character value in console output with a text message
**/
private static void debug(char value, String message) {
if (System.getProperty("ONLINE_JUDGE") == null) {
if (message.charAt(message.length() - 1) != ' ') message += " ";
System.out.println(message + "" + value);
}
}
/**
* method to print double value in console output
**/
private static void debug(double value) {
if (System.getProperty("ONLINE_JUDGE") == null) {
System.out.println("Double value = " + value);
}
}
/**
* method to print double value in console output with a text message
**/
private static void debug(double value, String message) {
if (System.getProperty("ONLINE_JUDGE") == null) {
if (message.charAt(message.length() - 1) != ' ') message += " ";
System.out.println(message + "" + value);
}
}
/**
* method to print integer type array value in console output
**/
private static void debug(int[] arr) {
if (System.getProperty("ONLINE_JUDGE") == null) {
int n = arr.length;
System.out.print("[");
for (int i = 0; i < n; i++) {
if (i < n - 1) System.out.print(arr[i] + ", ");
else System.out.print(arr[i]);
}
System.out.println("]");
}
}
/**
* method to print long type array value in console output
**/
private static void debug(long[] arr) {
if (System.getProperty("ONLINE_JUDGE") == null) {
int n = arr.length;
System.out.print("[");
for (int i = 0; i < n; i++) {
if (i < n - 1) System.out.print(arr[i] + ", ");
else System.out.print(arr[i]);
}
System.out.println("]");
}
}
/**
* method to print long type array value in console output
**/
private static void debug(String[] arr) {
if (System.getProperty("ONLINE_JUDGE") == null) {
int n = arr.length;
System.out.print("[");
for (int i = 0; i < n; i++) {
if (i < n - 1) System.out.print(arr[i] + ", ");
else System.out.print(arr[i]);
}
System.out.println("]");
}
}
/**
* method to print char type array value in console output
**/
private static void debug(char[] arr) {
if (System.getProperty("ONLINE_JUDGE") == null) {
int n = arr.length;
System.out.print("[");
for (int i = 0; i < n; i++) {
if (i < n - 1) System.out.print(arr[i] + ", ");
else System.out.print(arr[i]);
}
System.out.println("]");
}
}
/**
* method to print double type array value in console output
**/
private static void debug(double[] arr) {
if (System.getProperty("ONLINE_JUDGE") == null) {
int n = arr.length;
System.out.print("[");
for (int i = 0; i < n; i++) {
if (i < n - 1) System.out.print(arr[i] + ", ");
else System.out.print(arr[i]);
}
System.out.println("]");
}
}
/**
* please ignore the below code as it's just used for
* taking faster input in java
*/
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();
}
}
} | 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 8 | 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< 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 | 2a0946bb07a09f4265f562b4dd153748 | 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 < 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 Main implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
public static void main(String[] args) {
new Thread(null, new Main(), "", 256 * (1L << 20)).start();
}
public void run() {
try {
long t1 = System.currentTimeMillis();
if (System.getProperty("ONLINE_JUDGE") != null) {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
} else {
in = new BufferedReader(new FileReader("input.txt"));
out = new PrintWriter("output.txt");
}
Locale.setDefault(Locale.US);
solve();
in.close();
out.close();
long t2 = System.currentTimeMillis();
System.err.println("Time = " + (t2 - t1));
} catch (Throwable t) {
t.printStackTrace(System.err);
System.exit(-1);
}
}
String readString() throws IOException {
while (!tok.hasMoreTokens()) {
tok = new StringTokenizer(in.readLine());
}
return tok.nextToken();
}
int readInt() throws IOException {
return Integer.parseInt(readString());
}
long readLong() throws IOException {
return Long.parseLong(readString());
}
double readDouble() throws IOException {
return Double.parseDouble(readString());
}
long[] readLongArray(int n) throws IOException{
long[] array = new long[n];
for (int i = 0; i < n; i++) {
array[i] = readLong();
}
return array;
}
int[] readIntArray(int n) throws IOException{
int[] array = new int[n];
for (int i = 0; i < n; i++) {
array[i] = readInt();
}
return array;
}
// if using Long array with Long search swap the input parameters to longs
int bsForMinNumberGreaterEqual(int[] n, int search) {
int lowB = 0;
int highB = n.length - 1;
int k;
while (lowB <= highB) {
k = (lowB + highB) / 2;
if (k > 0 && n[k] >= search && n[k - 1] < search) {
return k;
} else if (k == 0 && n[k] >= search) {
return k;
} else if (k > 0 && n[k - 1] >= search) {
highB = k - 1;
} else if (n[k] < search) {
lowB = k + 1;
}
}
return -1;
}
static final Random random=new Random();
static void ruffleSort(int[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static void ruffleSort(long[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi = random.nextInt(n);
long temp = a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
void solveTest() throws IOException {
long n = readLong();
long s = readLong();
out.println(s / (n * n));
}
void solve() throws IOException {
int testCases = readInt();
for (int tests = 0; tests < testCases; tests++) {
solveTest();
}
}
}
| 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 8 | 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< 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 | a2b8576065a23833b53474f94fd9ba84 | 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 < 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.util.stream.*;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
StringBuilder result = new StringBuilder();
for(int i = 0; i < t; i++) {
long n = scan.nextLong();
long s = scan.nextLong();
long res = (s/(n*n));
result.append(res + "\n");
}
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 8 | 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< 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 | 58be29304528c6b2188a58a6c9bdc7c9 | 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 < 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.math.*;
public class SquareCounting
{
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 8 | 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< 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 | a3f53db7c2f21d4cfb96554a550d73f9 | 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 < 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 t = sc.nextInt();
while(t-->0){
long n = sc.nextLong();
long s = sc.nextLong();
long sq =n*n;
if(s<sq){
System.out.println(0);
}else{
System.out.println(s/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 8 | 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< 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 | 201d3e7cc3bd96c94fc77a710e5f0dd2 | 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 < 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 practice {
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
int t= s.nextInt();
while(t-->0) {
long n= s.nextLong();
long sum= s.nextLong();
System.out.println(sum/(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 8 | 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< 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 | 97bea205bfb7c9042501850ccbf77ec0 | 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 < 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 Main
{
public static void main(String args[]) throws java.lang.Exception
{
FastScanner input = new FastScanner();
int tc = input.nextInt();
work:
while (tc-- > 0) {
long n = input.nextLong();
long s = input.nextLong();
long square = n*n;
System.out.println(s/square);
}
}
static class FastScanner
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next()
{
while (!st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine() throws IOException
{
return br.readLine();
}
}
}
| 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 8 | 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< 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 | 409f771b323d9aa5ef132e37df708847 | 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 < 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 final class Main {
//int 2e9 - long 9e18
static PrintWriter out = new PrintWriter(System.out);
static FastReader in = new FastReader();
static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(0, 1), new Pair(1, 0), new Pair(0, -1)};
static int mod = (int) (1e9 + 7);
static int mod2 = 998244353;
public static void main(String[] args) {
int tt = i();
while (tt-- > 0) {
solve();
}
out.flush();
}
public static void solve() {
int n = i();
long s = l();
out.println(s / ((long) n * n));
}
// (10,5) = 2 ,(11,5) = 3
static long upperDiv(long a, long b) {
return (a / b) + ((a % b == 0) ? 0 : 1);
}
static long sum(int[] a) {
long sum = 0;
for (int x : a) {
sum += x;
}
return sum;
}
static int[] preint(int[] a) {
int[] pre = new int[a.length + 1];
pre[0] = 0;
for (int i = 0; i < a.length; i++) {
pre[i + 1] = pre[i] + a[i];
}
return pre;
}
static long[] pre(int[] a) {
long[] pre = new long[a.length + 1];
pre[0] = 0;
for (int i = 0; i < a.length; i++) {
pre[i + 1] = pre[i] + a[i];
}
return pre;
}
static long[] post(int[] a) {
long[] post = new long[a.length + 1];
post[0] = 0;
for (int i = 0; i < a.length; i++) {
post[i + 1] = post[i] + a[a.length - 1 - i];
}
return post;
}
static long[] pre(long[] a) {
long[] pre = new long[a.length + 1];
pre[0] = 0;
for (int i = 0; i < a.length; i++) {
pre[i + 1] = pre[i] + a[i];
}
return pre;
}
static void print(char A[]) {
for (char c : A) {
out.print(c);
}
out.println();
}
static void print(boolean A[]) {
for (boolean c : A) {
out.print(c + " ");
}
out.println();
}
static void print(int A[]) {
for (int c : A) {
out.print(c + " ");
}
out.println();
}
static void print(long A[]) {
for (long i : A) {
out.print(i + " ");
}
out.println();
}
static void print(List<Integer> A) {
for (int a : A) {
out.print(a + " ");
}
}
static int i() {
return in.nextInt();
}
static long l() {
return in.nextLong();
}
static double d() {
return in.nextDouble();
}
static String s() {
return in.nextLine();
}
static String c() {
return in.next();
}
static int[][] inputWithIdx(int N) {
int A[][] = new int[N][2];
for (int i = 0; i < N; i++) {
A[i] = new int[]{i, in.nextInt()};
}
return A;
}
static int[] input(int N) {
int A[] = new int[N];
for (int i = 0; i < N; i++) {
A[i] = in.nextInt();
}
return A;
}
static long[] inputLong(int N) {
long A[] = new long[N];
for (int i = 0; i < A.length; i++) {
A[i] = in.nextLong();
}
return A;
}
static int GCD(int a, int b) {
if (b == 0) {
return a;
} else {
return GCD(b, a % b);
}
}
static long GCD(long a, long b) {
if (b == 0) {
return a;
} else {
return GCD(b, a % b);
}
}
static long LCM(int a, int b) {
return (long) a / GCD(a, b) * b;
}
static long LCM(long a, long b) {
return a / GCD(a, b) * b;
}
// find highest i which satisfy a[i]<=x
static int lowerbound(int[] a, int x) {
int l = 0;
int r = a.length - 1;
while (l < r) {
int m = (l + r + 1) / 2;
if (a[m] <= x) {
l = m;
} else {
r = m - 1;
}
}
return l;
}
static void shuffle(int[] arr) {
for (int i = 0; i < arr.length; i++) {
int rand = (int) (Math.random() * arr.length);
int temp = arr[rand];
arr[rand] = arr[i];
arr[i] = temp;
}
}
static void shuffleAndSort(int[] arr) {
for (int i = 0; i < arr.length; i++) {
int rand = (int) (Math.random() * arr.length);
int temp = arr[rand];
arr[rand] = arr[i];
arr[i] = temp;
}
Arrays.sort(arr);
}
static void shuffleAndSort(int[][] arr, Comparator<? super int[]> comparator) {
for (int i = 0; i < arr.length; i++) {
int rand = (int) (Math.random() * arr.length);
int[] temp = arr[rand];
arr[rand] = arr[i];
arr[i] = temp;
}
Arrays.sort(arr, comparator);
}
static void shuffleAndSort(long[] arr) {
for (int i = 0; i < arr.length; i++) {
int rand = (int) (Math.random() * arr.length);
long temp = arr[rand];
arr[rand] = arr[i];
arr[i] = temp;
}
Arrays.sort(arr);
}
static boolean isPerfectSquare(double number) {
double sqrt = Math.sqrt(number);
return ((sqrt - Math.floor(sqrt)) == 0);
}
static void swap(int A[], int a, int b) {
int t = A[a];
A[a] = A[b];
A[b] = t;
}
static void swap(char A[], int a, int b) {
char t = A[a];
A[a] = A[b];
A[b] = t;
}
static long pow(long a, long b, int mod) {
long pow = 1;
long x = a;
while (b != 0) {
if ((b & 1) != 0) {
pow = (pow * x) % mod;
}
x = (x * x) % mod;
b /= 2;
}
return pow;
}
static long pow(long a, long b) {
long pow = 1;
long x = a;
while (b != 0) {
if ((b & 1) != 0) {
pow *= x;
}
x = x * x;
b /= 2;
}
return pow;
}
static long modInverse(long x, int mod) {
return pow(x, mod - 2, mod);
}
static boolean isPrime(long N) {
if (N <= 1) {
return false;
}
if (N <= 3) {
return true;
}
if (N % 2 == 0 || N % 3 == 0) {
return false;
}
for (int i = 5; i * i <= N; i = i + 6) {
if (N % i == 0 || N % (i + 2) == 0) {
return false;
}
}
return true;
}
public static String reverse(String str) {
if (str == null) {
return null;
}
return new StringBuilder(str).reverse().toString();
}
public static void reverse(int[] arr) {
for (int i = 0; i < arr.length / 2; i++) {
int tmp = arr[i];
arr[arr.length - 1 - i] = tmp;
arr[i] = arr[arr.length - 1 - i];
}
}
public static String repeat(char ch, int repeat) {
if (repeat <= 0) {
return "";
}
final char[] buf = new char[repeat];
for (int i = repeat - 1; i >= 0; i--) {
buf[i] = ch;
}
return new String(buf);
}
public static int[] manacher(String s) {
char[] chars = s.toCharArray();
int n = s.length();
int[] d1 = new int[n];
for (int i = 0, l = 0, r = -1; i < n; i++) {
int k = (i > r) ? 1 : Math.min(d1[l + r - i], r - i + 1);
while (0 <= i - k && i + k < n && chars[i - k] == chars[i + k]) {
k++;
}
d1[i] = k--;
if (i + k > r) {
l = i - k;
r = i + k;
}
}
return d1;
}
public static int[] kmp(String s) {
int n = s.length();
int[] res = new int[n];
for (int i = 1; i < n; ++i) {
int j = res[i - 1];
while (j > 0 && s.charAt(i) != s.charAt(j)) {
j = res[j - 1];
}
if (s.charAt(i) == s.charAt(j)) {
++j;
}
res[i] = j;
}
return res;
}
}
class Pair {
int i;
int j;
Pair(int i, int j) {
this.i = i;
this.j = j;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Pair pair = (Pair) o;
return i == pair.i && j == pair.j;
}
@Override
public int hashCode() {
return Objects.hash(i, j);
}
}
class ThreePair {
int i;
int j;
int k;
ThreePair(int i, int j, int k) {
this.i = i;
this.j = j;
this.k = k;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ThreePair pair = (ThreePair) o;
return i == pair.i && j == pair.j && k == pair.k;
}
@Override
public int hashCode() {
return Objects.hash(i, j);
}
}
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;
}
}
class Node {
int val;
public Node(int val) {
this.val = val;
}
}
class ST {
int n;
Node[] st;
ST(int n) {
this.n = n;
st = new Node[4 * Integer.highestOneBit(n)];
}
void build(Node[] nodes) {
build(0, 0, n - 1, nodes);
}
private void build(int id, int l, int r, Node[] nodes) {
if (l == r) {
st[id] = nodes[l];
return;
}
int mid = (l + r) >> 1;
build((id << 1) + 1, l, mid, nodes);
build((id << 1) + 2, mid + 1, r, nodes);
st[id] = comb(st[(id << 1) + 1], st[(id << 1) + 2]);
}
void update(int i, Node node) {
update(0, 0, n - 1, i, node);
}
private void update(int id, int l, int r, int i, Node node) {
if (i < l || r < i) {
return;
}
if (l == r) {
st[id] = node;
return;
}
int mid = (l + r) >> 1;
update((id << 1) + 1, l, mid, i, node);
update((id << 1) + 2, mid + 1, r, i, node);
st[id] = comb(st[(id << 1) + 1], st[(id << 1) + 2]);
}
Node get(int x, int y) {
return get(0, 0, n - 1, x, y);
}
private Node get(int id, int l, int r, int x, int y) {
if (x > r || y < l) {
return new Node(0);
}
if (x <= l && r <= y) {
return st[id];
}
int mid = (l + r) >> 1;
return comb(get((id << 1) + 1, l, mid, x, y), get((id << 1) + 2, mid + 1, r, x, y));
}
Node comb(Node a, Node b) {
if (a == null) {
return b;
}
if (b == null) {
return a;
}
return new Node(GCD(a.val, b.val));
}
static int GCD(int a, int b) {
if (b == 0) {
return a;
} else {
return GCD(b, a % b);
}
}
} | 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 8 | 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< 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 | 3e78047ac3223f538ec0a5d2e8855832 | 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 < 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 Q1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int test = in.nextInt();
while(test-->0) {
long n = in.nextLong();
long s = in.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 8 | 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< 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 |
Subsets and Splits