exec_outcome
stringclasses
1 value
code_uid
stringlengths
32
32
file_name
stringclasses
111 values
prob_desc_created_at
stringlengths
10
10
prob_desc_description
stringlengths
63
3.8k
prob_desc_memory_limit
stringclasses
18 values
source_code
stringlengths
117
65.5k
lang_cluster
stringclasses
1 value
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_time_limit
stringclasses
27 values
prob_desc_sample_outputs
stringlengths
2
796
prob_desc_notes
stringlengths
4
3k
lang
stringclasses
5 values
prob_desc_input_from
stringclasses
3 values
tags
listlengths
0
11
src_uid
stringlengths
32
32
prob_desc_input_spec
stringlengths
28
2.37k
difficulty
int64
-1
3.5k
prob_desc_output_spec
stringlengths
17
1.47k
prob_desc_output_to
stringclasses
3 values
hidden_unit_tests
stringclasses
1 value
PASSED
df19c70396e6d1827f31e3d6e62eff75
train_110.jsonl
1646408100
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially...
256 megabytes
import com.sun.jmx.remote.internal.ArrayQueue; import java.util.*; import java.io.*; public class Solution { static List<Integer>[] graph; static int[] parent; static Node[][] dp; static boolean[] isGood; public static void main(String[] args) throws IOException { Scanner in = new Scann...
Java
["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"]
2 seconds
["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"]
NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "dp", "implementation", "trees" ]
dc3848faf577c5a49273020a14b343e1
The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree.
2,000
In the first line print two integers  — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$)  — the corresponding weight assigned to each vertex. It can be proven that there exists an ...
standard output
PASSED
a7bbc6ef5ec1da0d904ee8c500a16630
train_110.jsonl
1646408100
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; //import java.text.DecimalFormat; import java.util.*; public class Codeforces { static long mod = 1000000007 ; public static void main(String[] args) throws Exception { PrintWri...
Java
["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"]
2 seconds
["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"]
NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "dp", "implementation", "trees" ]
dc3848faf577c5a49273020a14b343e1
The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree.
2,000
In the first line print two integers  — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$)  — the corresponding weight assigned to each vertex. It can be proven that there exists an ...
standard output
PASSED
27344d89944d1e75dabdf94e9fb95687
train_110.jsonl
1646408100
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author...
Java
["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"]
2 seconds
["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"]
NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "dp", "implementation", "trees" ]
dc3848faf577c5a49273020a14b343e1
The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree.
2,000
In the first line print two integers  — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$)  — the corresponding weight assigned to each vertex. It can be proven that there exists an ...
standard output
PASSED
2b9a4ea8c659efce8893f912226a47b9
train_110.jsonl
1646408100
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Random; import java.util.StringTokenizer; /* */ public class D { public stat...
Java
["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"]
2 seconds
["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"]
NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "dp", "implementation", "trees" ]
dc3848faf577c5a49273020a14b343e1
The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree.
2,000
In the first line print two integers  — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$)  — the corresponding weight assigned to each vertex. It can be proven that there exists an ...
standard output
PASSED
35a25a93d6cba0e72ae611cf53c5ff31
train_110.jsonl
1646408100
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class Round774D { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String IMPO...
Java
["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"]
2 seconds
["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"]
NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+...
Java 17
standard input
[ "constructive algorithms", "dfs and similar", "dp", "implementation", "trees" ]
dc3848faf577c5a49273020a14b343e1
The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree.
2,000
In the first line print two integers  — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$)  — the corresponding weight assigned to each vertex. It can be proven that there exists an ...
standard output
PASSED
46fc014566e8fdd3971b4cab0391f811
train_110.jsonl
1646408100
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially...
256 megabytes
import java.io.*; import java.util.*; public class WeightTheTree { public static void solve(FastIO io) { final int N = io.nextInt(); Node[] nodes = new Node[N + 1]; for (int i = 1; i <= N; ++i) { nodes[i] = new Node(i); } for (int i = 1; i < N; ++i) { final int U = io.nextInt(); ...
Java
["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"]
2 seconds
["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"]
NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+...
Java 17
standard input
[ "constructive algorithms", "dfs and similar", "dp", "implementation", "trees" ]
dc3848faf577c5a49273020a14b343e1
The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree.
2,000
In the first line print two integers  — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$)  — the corresponding weight assigned to each vertex. It can be proven that there exists an ...
standard output
PASSED
85a806f2989dafdb30758dcc3805b40e
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class RoundDeltixAutumn2021C { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final stati...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 17
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
163f36677e7334213a1a19f226f4e7fe
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; // https://codeforces.com/contest/1609/problem/C public class C { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int M = 1000010; boolean[] primes = ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
59c45ac9649cdbe520619b8c5d427a3a
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class C { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int M = 1000010; boolean[] primes = new boolean[M]; for(int i = 2; i < M; i++) ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
04fc66d608e5cb099b3c1232b078b268
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class cses{ static boolean[] primes = new boolean[1000000 + 1]; public static void main(String[] args) { Arrays.fill(primes, true); primes[0] = primes[1] = false; for (int i = 2; i < primes.length; i++) { if(primes[i] && ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
2dbb1207f055d6736d492c157e992808
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; import java.io.*; public class pro3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int casess = input.nextInt(); ArrayList<Integer> arr = new ArrayList<>(); do { i...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
4addbcfcbec9cd353b517e4e1548a4b9
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class C1 { static HashSet<Long> primes = new HashSet<Long>(); public static void main (String[] args) throws IOException { Kattio io = new Kattio(); sieveOfEratosthenes(1000001); int t = io.nextInt(); //System.out.println(primes.contains(880667)); //System.out...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
6f41dd115d4d32ca9dbc3b94eb726a2d
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); public static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public static int mod = (int)1e9+7; static boolean[] isprime...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
245d064275f9428c0c1d7d9d22e0e99e
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); public static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public static int mod = (int)1e9+7; static boolean[] isprime...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
a4807292ff344b0b60bd7c83bdd87d30
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; public class snackDown3 { public static class FastReader { BufferedReader b; StringTokenizer s; public FastReader() { b=new BufferedReader(new InputStreamReader(System.in)); } String next() { while(s==null...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
7465e570c734496f3dfa43f9848f77f6
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.BitSet; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Set; import java.util.StringTokenizer; public clas...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
59e2498a40cf0ba1202345243a376f38
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class A3x { void solve() { int n = cint(); int step = cint(); int[] a = carr_int(n); int[] left1 = new int[n]; int[] right1 = new int[n]; for (int i = 0; i < n; i++) { if (a[i]...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
f339626808dcdc54a08524a50ef44001
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.BitSet; import java.util.Random; public class A3 { void solve() throws Exception { String line = in.readLine(); String[] p = line.split("[\\s]"); int n = Integer.parseIn...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
ae008c8482c53e331a0b6d67586026ec
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.HashMap; import java.util.StringTokenizer; /** * * @author eslam */ public class ComplexMarketAnalysis { static class Fas...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
e460a9adde1b95cc1e66feac2ab55a96
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.HashMap; import java.util.StringTokenizer; /** * * @author eslam */ public class ComplexMarketAnalysis { static class Fas...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
7d8e0d0caeb0d0e34e483c1a6636a061
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.Arrays; import java.util.Scanner; //Complex Market Analysis public class ComplexMarketAnalysis { public static void main(String[] args) { ComplexMarketAnalysis.solution(); } public static void solution() { Scanner scanner = new Scanner(System.in); int numCases = I...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
dfc91a93363a63771ee55d0895000844
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int numCases = Integer.parseInt(scanner.nextLine()); for (int i = 0; i < numC...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
15b248eeebfdd0e7f616b8c26bd327e3
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.File; import java.io.FileInputStream; import java.util.*; public class Main { // static final File ip = new File("input.txt"); // static final File op = new File("...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
2af029062704a5fa258fb694b62dea1c
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.Scanner; public class ProblemC { static boolean[] nPrimes; public static void main(String[] args) { nPrimes = new boolean[1000001]; nPrimes[0] = true; nPrimes[1] = true; int t1 = 2; while (t1 < 1000) { for (int i = 2 * t1; i <= ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
df8aa600d668ef2a8ffa01d9fde49811
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class JaiShreeRam{ static Scanner in=new Scanner(); static long mod = 1000000007; static ArrayList<ArrayList<Integer>> adj; static int seive[]=new int[1000001]; public static void main(String[...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
0b371091a18c09a3391faa59edd4b1a6
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import j...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
1d6f27ae26750e8dd1494fadfc3c6abd
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import j...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
46c219fc34829d6467e4626d74d227bf
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import j...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
af486c83412157cb2489b80dbbcc4cbc
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeSet; public class c1609C { private SimpleInputReader in; private SimpleOutputWriter out; Set<Integer> primes = sieve(); public c1609C(Reader r, Writer w) { ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
e210700004c89acfacdb0728a159616c
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class cp { static int mod=(int)1e9+7; // static Reader sc=new Reader(); static FastReader sc=new FastReader(System.in); static int[] sp; static int size=(int)1e6; static int[] arInt; static long[] arLong; public static void main(String[] args) throws...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
4f150adcb8c8af944e412e6f6e77d8d0
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); BufferedWriter output = new BufferedWri...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
616a6a95ee22ccfceb85fa8d313e921a
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class Main { public static int mod = (int) 1e9 + 7; public static int imax = Integer.MAX_VALUE; public static long lmax = Long.MAX_VALUE; public static PrintWriter out = new PrintWriter(System.out); // **** -----> Disjoin...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
961b6d5ce1570009d82d91eff7c249d8
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; public class Sol { public static void sieveOfEratosthenes(boolean prime[]) { int n=prime.length; for (int i = 0; i < n; i++) prime[i] = true; for (int p = 2; p * p < n; p++){ if (prime[p] == true) { for (int i = p * p; i < n; i += p) prime...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
4106afa86a660c9186ad686d7c3e205a
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; import java.io.*; public class Main { // Graph // prefix sums //inputs public static void main(String args[])throws Exception{ Input sc=new Input(); precalcul...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
e7584c50c4e81502fe832e476828fa8b
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
7352bf4e37b47f628b00d3e190d5f034
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.*; public class weird_algrithm { static BufferedWriter output = new BufferedWriter( new OutputStreamWriter(Syst...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
21fd8a5d5bf630c206e52d9f386faf79
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; public class Main{ static boolean [] prime; public static void sieveOfEratosthenes(int n) { prime = new boolean[n + 1]; for (int i = 0; i <= n; i++) prime[i] = true; for (int p = 2; p * p <= n; p++) { // If pri...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
5018be9ea923f3adcc557895b3ea1453
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class C { private static final int MAX = (int)1e6; private boolean primes[] = new boolean[MAX + 1]; void go() { // add code int n = Reader.nextInt(); int e = Reader.nextInt(); int[] arr = new int[n]; long ans = ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
94d3f384fd487f876f5002ac1b7d560d
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; import java.io.OutputStreamW...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
72e451733ee90db5958a8c1a3266ef68
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class c { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int numcases = Integer.parseInt(in.readLine()); ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
3a4a11c263347395e5c33250d832a36f
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.lang.Math.ceil; import static java.util.Arrays.sort; public class C { static boolean[] isPrime = new boolean[1000055]; public static void main(String[] args) throws IOException { int t = ri(); ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
65a62a625cc62deefb5d0c53cca36aeb
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class C { // -- static variables --- // static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static int mod = (int) 1000000007; public static void main(String[] args) throws Exception { ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
f5df7bfc44b370c74c195ef79740fc8d
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class C { // -- static variables --- // static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static int mod = (int) 1000000007; public static void main(String[] args) throws Exception { ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
8d603485a73757aa0a160b6fe8d92d1f
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long mod = 1000000007; static long max ; static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); int t = sc.nextIn...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
5f9a1f726adba92751ab2eeab7559229
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long mod = 1000000007; static long max ; static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); int t = sc.nextIn...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
d8c05c0489b519f65ba34ebdf598343d
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class Main { static boolean prime[]; public static void main(String[] args) { sieveOfEratosthenes(1000009); // System.out.println(prime[1]=false); prime[1]=false; FastScanner fs=new FastScanner(); /****** CODE STARTS HERE *****/ ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
41b6b73c2e0cac8763425c31e951a829
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.StringTokenizer; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.lang.reflect.Array; import java.io.IOException; import java.io.BufferedReader; import java.io.BufferedWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; i...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
78636fe8bc0fe6aa68dc4ba76237629e
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main { //-----------PrintWriter for faster output--------------------------------- public static PrintWriter out; public static int cnt; //-----------MyScanner class for faster input---------- public static class MySca...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
9643c6f64d64d7c0c79562f324639615
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { int[] primes = new int[1000001]; for (int i = 2; i < primes.length; i++) { for (int j = i; j < primes.length; j += i) { if (primes[j] == 0)...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
8dd0e6070e8e7ff2d517d2ec0e6a291e
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.math.BigInteger; import java.util.*; import java.io.*; public class CodeForces { boolean isPrime(int x) { if (x < 2) { return false; } int xq = (int)Math.sqrt((double)x); for (int i = 2; i <= xq; i++) { if (x % i == 0) { ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
cc12f47dacaaf9a9535080207806bd48
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class Main{ private static final boolean console = true; private static final String name = "closing"; private static PrintWriter out; private static FastIO sc; private static final int mod = 1_000_000_007; public static void main(String[] args) throws Exc...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
35a225188f2d4dd3f0ec7c0ebc2b3352
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class Solution { static Set<Integer> sieve; public static void main(String[] args) { MyScanner s = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int testcases=s.nextInt(); sieve(); ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
cd8cf2bc9b21b8b134f947f779d60006
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; // Ctrl + Alt + F for formatting code public class setup { static int mod = (int)1e9 + 7; static long gcd(long a, long b, long n) { if (a == b) { return (power(a, n, mod) + power(b, n, mod)) % mod; } long num = a - b, max = 1; for (int i = 1; i * i ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
e155dab8c1543b39c8eb9bd4b2ebb605
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static void main(String args[]){ InputReader in=new InputReader(System.in); TASK solver = new TASK(); int t=1; t = in.nextInt(); for(int i=1;i<=t;i++) { ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
db753235f9e3933aaad359a8657e04f4
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.*; public class Codeforces { static int mod= 1000000007; static boolean isp[]=new boolean[1000005]; public static void main(String...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
f088b81e7a4af775bdf41de54f2a73c9
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
// package faltu; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; //import java.security.KeyStore.Entry; import java.util.*; import java.util.Map.Entry; public class Main { static long LowerBound(long[] a2, long x) { // x is the target value or key int l=...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
f7ef8a36d473cf7a57e0e85937fd1889
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class C_Complex_Market_Analysis{ public static void main (String[] args){ final int MAXN = 1000001; FastReader s = new FastReader(); int t=1;t=s.ni(); boolean[] isPrime = new boolean[MAXN]; Arrays.fill(isPrime, true); ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
fbc425f8482715b4b5b98cb3c7eb6979
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Solutionc { static boolean isPrime(int num) { if(num == 1) return false; if(num == 2) return true; for(int i=2;i*i<=num;++i) { if(num%i == 0) return false; } return tr...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
c536de6278f81dcdee3949d86a3582bd
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.Scanner; public class PS1609C { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int cases = Integer.parseInt(scanner.next()); for (int i = 0; i < cases; i++) { int n = Integer.parseInt(scanner.next()); int e = Integ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
0cb2f62d86d8e482f97019ecd7af05af
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class C{ public static void main(String[] args){ FastReader sc = new FastReader(); boolean prime[]=sieve_of_Eratosthenes(1000001); int t=sc.nextInt(); while(t-->0){ int n=sc.ne...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
5dad0f7e6145ef4e8cbf02d638a45532
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class CodeForces{ /*-------------------------------------------EDITING CODE STARTS HERE-------------------------------------------*/ public static void main(String[] args) throws IOException{ openIO(); int testCase = 1; testCase = sc.nextInt...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
4457841d8f1fb81fb3c42169d7e8401b
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.lang.*; public class c { // static int mod = 998244353; static int mod = 1000000007; public static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private by...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
8b647fdbd51784a2332e9253f55831cb
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef {static class FastReader { BufferedReader br; StringTokenizer st; pub...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
91179b521ec67f442ca11a85ca2b2884
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.PrintWriter; /* Solution Created: 18:00:58 28/11/2021 C...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
950689920192c22e3a1ff0e20d7fdd18
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; public class C_Complex_Market_Analysis { static long mod = Long.MAX_VALUE; public static void main(String[] args) { OutputStrea...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
7750691513ca3a26a77b286e6146eee7
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; import java.io.ObjectInputFilter.Status; public class CodeForces { static privat...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
cb9161365cdbce098011cdef1e939bbc
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.lang.Math; import java.lang.reflect.Array; import java.util.*; import javax.swing.text.DefaultStyledDocument.ElementSpec; public final class Solution { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static BufferedWriter bw = new B...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
b2e9e29a9b33bd24cd4da3937bdf8185
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
//Some of the methods are copied from GeeksforGeeks Website import java.util.*; import java.lang.*; import java.io.*; public class Main { //static Scanner sc=new Scanner(System.in); static Reader sc=new Reader(); // static FastReader sc=new FastReader(System.in); static long mod = (long)(1e9)+ ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
7e59dd1250c803d9f31820ca2acbf1f0
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
/*----------- ---------------* Author : Ryan Ranaut __Hope is a big word, never lose it__ ------------- --------------*/ import java.io.*; import java.util.*; public class Codeforces1 { static PrintWriter ou...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
7edb31ea289cdf5c32bbc4331990a201
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
b71b4dd5f5439e003fa9342e11c972a5
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; import java.time.*; import static java.lang.Math.*; @SuppressWarnings("unused") public class B { static boolean DEBUG = false; static Reader fs; static PrintWriter pw; public static ArrayList<Integer> sieve(int n) { int prime[] = new int[n + 1]; ArrayList<I...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
8ceade9dfd2b3682b7b1b736e3f5fedb
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class a { static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static boolean prime[]; public static void main (String[] args) throws java.lang.Exception { int t = sc.nextIn...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
ce5c9f91300ada69946b7c5531aa8b97
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; import static java.lang.Math.max; public class A { static PrintW...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
9c5adcefaf65fef5ed1f032319e9d80f
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.lang.reflect.Array; import java.util.*; public class Main { public static void main(String[] args) { // write your code here Scanner sc = new Scanner(System.in); boolean[] isPrime = seive(); int t = sc.nextInt(); while (t-->0){ int n ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
87ebfcb879b1f3275f8d886daa61d084
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
/** * * YUVRAJ PARASHAR * * */ import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; public class Cp{ public static void main(String[] args) { /*==============Sieve of Eratosthenes============...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
58c458f0fb7a9974f430ff2bb17f683e
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
7a0c1b4f4f1e686336fa9db261ed9080
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Deque; import java.uti...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
a298fd6fd569b6e41cbaafd0ad60110e
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException; import java.io.IOException;import java.io.InputStream;import java.io.PrintWriter; import java.security.AccessControlException;import java.util.ArrayList;import java.util.Arrays; import java.util.List;import java.util.TreeSet;public...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
b643ea5380d1412588a22a626d099c70
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Solution{ static long mod=(long)1e9+7; static boolean[] prime=sieveOfEratosthenes(((int)1e6+7)); static FastScanner sc = new FastScanner(); public static void solve(){ int n...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
d0864927d40265243bed3ec252bf4140
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; public class codeforceb { //ArrayList<Integer> arr2=new ArrayList<Integer>(); //ArrayList<Integer> arr1=new ArrayList<Integer>(); //Map<Integer,Integer> hm=new HashMap<Integer,Integer>(); //Set<Integer> st1=new HashSet<Integer>(); static Set<Integer> prime=new...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
db8242445f99458cb9412a357d57cf63
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
/* بسم الله الرحمن الرحيم /$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ |__ $$ /$$__ $$ |$$ |$$ /$$__ $$ | $$| $$ \ $$| $$|$...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
11708ad7dee9f53143a6ced741658f3e
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; public class Main{ static boolean [] prime; public static void sieveOfEratosthenes(int n) { prime = new boolean[n + 1]; for (int i = 0; i <= n; i++) prime[i] = true; for (int p = 2; p * p <= n; p++) { // ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
347b0ef9010172e7c78c743ca2e728a6
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; public class ComplexMarketAnalysis_C { private static boolean isPrime(int n) { if(n==1) { return false; } for(int i = 2; i*i<=n; i++) { if(n%i==0) { return false; } } return true; } public static void main(String[] args) { // TODO Auto-generated metho...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
84d5d9f44a0a1db5ba54b69764b05a06
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; // @author : Dinosparton public class test { static class Pair{ long x; long y; Pair(long x,long y){ this.x = x; this.y = y; } } static class Sort implements Comparator<Pa...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
09ede864f0dbebe7a9215cd2e8cc7de6
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; im...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
b115536bc9d6e6df8da441346bda3224
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
// C import java.util.*; import java.io.*; // THIS TEMPLATE MADE BY AKSH BANSAL. public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
32baab4f7e5e9055566549200de0338e
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class DIv21609C { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int N = 10...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
9fdda87d2b2010dff32b61705932e27d
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
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.HashSet; import java.util.Set; import java.util.StringTokenizer; public class TaskC { final static Set<Integer> primeNums = new HashSet<>(); fi...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
f12635ba5c3aff6211eb81d10d81f916
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class C { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
9d26b235b7b0994e3b06388b542d549c
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.Scanner; public class C { public static void main(String[] args) { Scanner s = new Scanner(System.in); int lines = s.nextInt(); s.nextLine(); for (int i = 0; i < lines; i += 1) { solve(s.nextInt(), s.nextInt(), s); } } ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
eb252edb8e0fb52bf8b7db627c0b876a
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { private static FS sc = new FS(); private static class FS { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { w...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
69c0c276cf808b050511e0b1de55be69
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class C { static FastScanner sc = new FastScanner(); static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static HashSet<Integer>prime = new HashSet<>(); public static void init(){ int p = (int)1e6 + 1; ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
ce9cb87f4ed5f505fa02066d45e695a7
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
/* Codeforces Problem 1609C */ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashSet; import java.util.Set; public class ComplexMarketAnalysis { public static void main(String[] args) throws IOException { FastIO in = new FastIO(System.in); ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
c9ed3695c37491628632d55ca0bcadfc
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class C { static long mod = (long) 1e9 + 7; static long mod1 = 998244353; static InputStream inputStream = System.in; static OutputStream outputStream =...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
8880c02b10a74db42c683eaf5dafa8eb
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStrea...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
2278b286afd16cbc2abe6b0db72d4506
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; import java.io.*; public class Deltix { public static void main(String[] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.nextInt(); linearSieve((int) ((1e6) + 1)); while ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
f01e5afd33b0eff995588ed3fd2c0ca9
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.util.*; public class C { public static final int MOD998 = 998244353; public static final int MOD100 = 1000000007; public static void main(String[] args) throws Exception { ContestScanner sc = new ContestScanner(); ContestPrinter cp = new ContestPrinter(); int T = sc.ne...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
4e92f8586772238550dc748bd4ba4de2
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
public class Main { public static void main(String[] args) { new Main(); } public Main() { FastScanner fs = new FastScanner(); java.io.PrintWriter out = new java.io.PrintWriter(System.out); solve(fs, out); out.flush(); } public void solve(FastScanner fs, java.io.PrintWriter out) { ...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
3887d79aff0682de1676bd420e134210
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args){ InputStream inputStream = System.in; Outp...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output
PASSED
2900f42d4f452fc685b77c6a6faac3b3
train_110.jsonl
1638110100
While performing complex market analysis William encountered the following problem:For a given array $$$a$$$ of size $$$n$$$ and a natural number $$$e$$$, calculate the number of pairs of natural numbers $$$(i, k)$$$ which satisfy the following conditions: $$$1 \le i, k$$$ $$$i + e \cdot k \le n$$$. Product $$$a_...
256 megabytes
import java.io.*; import java.util.*; public class zia { static boolean prime[] = new boolean[25001]; static void ruffleSort(int[] a) { int n=a.length; Random random = new Random(); for (int i=0; i<n; i++) { int oi=random.nextInt(n), temp=a[oi]; a[oi]=a[i]; a[...
Java
["6\n7 3\n10 2 1 3 1 19 3\n3 2\n1 13 1\n9 3\n2 4 2 1 1 1 1 4 2\n3 1\n1 1 1\n4 1\n1 2 1 1\n2 2\n1 2"]
2 seconds
["2\n0\n4\n0\n5\n0"]
NoteIn the first example test case two pairs satisfy the conditions: $$$i = 2, k = 1$$$, for which the product is: $$$a_{2} \cdot a_{5} = 2$$$ which is a prime number. $$$i = 3, k = 1$$$, for which the product is: $$$a_{3} \cdot a_{6} = 19$$$ which is a prime number. In the second example test case there are no pair...
Java 11
standard input
[ "binary search", "dp", "implementation", "number theory", "schedules", "two pointers" ]
32130f939336bb6f2deb4dfa5402867d
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$e$$$ $$$(1 \le e \le n \le 2 \cdot 10^5)$$$, the number of items in the array and num...
1,400
For each test case output the answer in the following format: Output one line containing the number of pairs of numbers $$$(i, k)$$$ which satisfy the conditions.
standard output