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
c2e97ad40a11b823639bec7961041c8e
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.awt.*; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Reader.init(System.in); BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out)); int t =1; while ( t > 0 ){ ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
f0e90a08035a535860bd3cca1993966f
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
/* "Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." Just have Patience + 1... */ import java.util.*; import java.lang.*; import ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
58150d31c338038db7fd13e041c2cb81
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
//some updates in import stuff 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 D{ static int mod = (int) (Math.pow(10, 9)+7); static final int dx[] = { -1, 0, 1, 0 }, dy[] =...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
ac4f8fbb56bbf7b8bc3de8459b88ce82
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
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.StringTokenizer; public class taskd { public static void main(String[] args) { FastScanner in = new FastScanner(); PrintWriter out =...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
a71bb06d32cc16c76be9ac8587b6bd87
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; public class NotAdding { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] terms = br.readLine().split(" "); HashSet<Integer> set = ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
771c757636befedd66c7e74e17698004
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class Scanner { Scanner(InputStream in) { this.in = in; } InputStream in; byte[] bb = new byte[1 << 15]; int i, n; byte getc() { if (i == n) { i = n = 0; try { n = in.read(bb); } catch (IOException e) {} } return i < n...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
d055472cfadba1131bee3aa3f9d706ff
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static final int MAX = (int) 1e6; public static int gcd(int a, int b) { while (a % b != 0) { int temp = b; b = a % b; a = temp; } return b; } public static void main(String...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
d740028d553b7bcf51f510418ca94712
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
/* Rating: 1367 Date: 15-01-2022 Time: 22-41-15 Author: Kartik Papney Linkedin: https://www.linkedin.com/in/kartik-papney-4951161a6/ Leetcode: https://leetcode.com/kartikpapney/ Codechef: https://www.codechef.com/users/kartikpapney */ import java.util.*; import java.io.BufferedRe...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
1165d4f83461a51efae19e555625fc53
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
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
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
0f5a845193d0687ec8c78d7c0239d7b1
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
/** * Created by Himanshu **/ import java.util.*; import java.io.*; import java.math.*; public class D1627 { public static void main(String[] args) throws IOException { PrintWriter out = new PrintWriter(System.out); Reader s = new Reader(); int n = s.i(); int [] arr ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
8da19c2d783ed4b99263013dd21d435d
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; public class D { public static final int MAX_A = 1000000; public static void main(String[] args) { var io = new Kattio(System.in, System.out); solve(io); io.close(); } public static void solve(Kattio io) { int n = io.nextInt(); ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
0b7e94a2c2245d373c2bd92ab3577867
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class new1{ static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } public static void main(String[] args) throws IOException{ BufferedWriter output = new BufferedWriter(new OutputStreamWr...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
cd140341949da50ff2f4de96026a22c2
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.PriorityQueue; import java.util.TreeSet; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Strin...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
16dae3e079ba31333b5531b3c23e9822
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*;import java.io.*;import java.math.*; public class Main{ public static void process(int t)throws IOException { int n = ni(); int max = 1000000; boolean[]arr = new boolean[max + 1]; for(int i = 0;i<n;i++){ arr[ni()] = true; } ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
95ed5281ef85fdf8582eb6cb07b1599d
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.Scanner; public class D { public static void main(String[] args) { Scanner s = new Scanner(System.in); solve(s.nextInt(), s); } public static void solve(int n, Scanner s) { boolean[] inside = new boolean[1000001]; for (int i = 0; i < n; i++)...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
67ccb9bb50c8db8cf2dcc1b494b44118
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
// \(≧▽≦)/ // Terminus // TODO : get good import java.io.*; import java.util.*; public class tank { static final FastScanner fs = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { int t = 1; while(t-- > 0) ru...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
1f4465d8aebd0b86e8593aced7835cee
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author nul...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
fb63dca89fbba41fb2fe80ae1955afa6
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args){ InputStream input...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
a888e068c21f7445b66b335c4ca73beb
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class CF1627D extends PrintWriter { CF1627D() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1627D o = new CF1627D(); o.main(); o.flush(); } static final int A = 1000000; int gcd(int a, int b) { return b ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
a0a13f4bfe6e9fdf74f3df10c91ff00b
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static int MOD = 1000000007; int MAX = 1000000; // After writing solution, quick scan for: // array out of bounds // special cases e.g. n=1? // npe, particularly in maps // // Big numbers arith...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
b35a851731a103c891ff8771d5378fb3
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.math.*; /** __ __ ( _) ( _) / / \\ / /\_\_ / / \\ / / | \ \ / / \\ / / |\ \ \ / / , \ , / / /| \ \ / / |\_ /| ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 11
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
1548e76dbfbda557e9953e7d432db64a
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class Round766D { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String IMPO...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 17
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
bb41b7058e30d223c499162f3062687b
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; /** * * @author eslam */ public class Solution { // Beginning of the solution static Kattio input = new Kattio(); static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out)); static ArrayList<Ar...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 17
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
10dd59109eb7be58940ebfecf019d769
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; public class Q4 { private static final int MAXN = 1000005; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] cnt = new int[MAXN]; int[] isPresent = new int[MAXN]; long[] numberOfWays = new long[MAXN]; for(int i=0;...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
4ceb93a54040f04c4008642b1fa30410
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.lang.invoke.MethodHandles; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.Collections; import java.util.Hash...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
5dc2f43d41661b7280822ecec0b52331
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.lang.*; public class Solution{ static class Graph{ public static class Vertex{ HashMap<Integer,Integer> nb= new HashMap<>(); // for neighbours of each vertex } public static HashM...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
58bcb6ecc8ab5fb9f7557cbef47a3335
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static int N = 1000010, M = 2 * N; static int MOD = (int)1e9 + 7; static double EPS = 1e-7; static int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1}; ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
6ffd0c16fc2898b77e1eebab06b12d00
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static int N = 1000010, M = 2 * N; static int MOD = (int)1e9 + 7; static double EPS = 1e-7; static int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1}; ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
bbd9de88a57bf0548aec1b441521a75b
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; ////*************************************************************************** /* public class E_Gardener_and_Tree implements Runnable{ public static void main(String[] args) throws Exception { new Thread(null, new E_Gardener_and_Tree(), "E_Gardener_and_Tr...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
9d1e0928ca3f447679d04d7db2c81c39
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /** * @author Naitik * */ public class Main { static FastReader sc=new FastReader(); static int dp[]; static boolean v[]; // static int mod=998244353;; static int mod=1000000007; static int max; static int bit[]; //st...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
6d8aafe9edaed773779e72d531925bc6
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main { static int N = 1000010; public static void main(String[] args) throws IOException { FastScanner f = new FastScanner(); PrintWriter w = new PrintWriter(System.out);...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
f7df64ba637bc25e61ca0dc5b3432096
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
/* * Everything is Hard * Before Easy * Jai Mata Dii */ import java.util.*; import java.io.*; public class Main { static class FastReader{ BufferedReader br;StringTokenizer st;public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}String next(){while (st == null || !st.h...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
d53540efc18d7fcb1fcce0a6866316f0
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.*; import java.util.concurrent.ThreadLocalRandom; public class a729 { public static void main(String...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
4d4c0c03638944354384d816e7c99f2a
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
//package codeforce.div2; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Colle...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
9c1e35983a2f421838b5a216fdc73138
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
//package codeforce.div2; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Colle...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
6934ce9c5f713fb3eb9531d3637b74cb
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; public class solution{ public static int gcd(int a, int b){ if(b == 0){ return a; } return gcd(b,a%b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean[] visited = new boolean[1000002]; for(int i = 1...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
c811f84409bd7ed27cae6b4a2e6f25e3
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; /** * * @author eslam */ public class Solution { // Beginning of the solution static Kattio input = new Kattio(); static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out)); static ArrayList<Ar...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
ffec7bb3f84ada6fda9d399ef047309d
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) { FastReader input=new FastReader(); PrintWriter out=new PrintWriter(System.out); int T=1; while(T-->0) { int n=input.nextInt(); int max=100...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
d53c08ad65fa7f0acca9097434c910e1
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int i, j, k, n, m, t, y, x, sum = 0; static long mod = 998244353; static FastScanner fs = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); static String str; static long ans; public static...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
f53d44ca0b84cb439115e0abdd6b34ee
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import javax.management.Query; import java.io.*; public class Contest1 { public static void main(String[] args) throws Exception { //Scanner sc=new Scanner(System.in); // int t=sc.nextInt(); // while(t-->0) {} int n=sc.nextInt(); int [] a=new...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
dbeb8eaa01db1d800ec2ac5a8f5f178d
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
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.*; /** * * @Har_Har_Mahadev */ /** * Main , Solution , Remove Public */ public class D { public static void process() throws IOException ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
9fbe1aa0d93d7c6d084b3d499f8ae89b
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
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.*; /** * * @Har_Har_Mahadev */ /** * Main , Solution , Remove Public */ public class D { public static void process() throws IOException ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
5bc2b81c99dd24151b85e6dfc88c90be
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.InputMismatchException; /** * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools */ public class Main { static InputReader sc=new InputReader(System.in); static int gcd(int a...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
a51754cb3fdeed075c79f76f6afebc28
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class A { //--------------------------INPUT READER---------------------------------// static class fs { public BufferedReader br; StringTokenizer st = new StringTokenizer(""); public fs() { this(System.in); } public fs(Inpu...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
1e7be18b90fe40df5baa589a6d2184f8
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
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.*; //import sun.jvm.hotspot.runtime.linux_aarch64.LinuxAARCH64JavaThreadPDAccess; public class B { static int mod= 998244353; ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
cb523ebda2e26b0a639672e33d2c7260
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
//package challenges.codeforces756; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.InputMismatchException; import java.util.List; public class Main { static InputReader in=new InputReader(System.in); static PrintWri...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
f85b8b9acddf917b18d04bace718c14c
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public final class D { public static void main(String[] args) { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N = fs.nextInt(); int[] arr = fs.readArray(N); int max = 0; in...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
91ff270c6b3966be9d137a937a767b58
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import javax.swing.*; import java.lang.reflect.Array; import java.text.DecimalFormat; import java.util.*; import java.lang.*; import java.io.*; import java.math.*; import java.util.stream.Stream; // Please name your class Main public class Main { static FastScanner fs=new FastScanner(); s...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
552ef932d1681ef95e1aa57e52e7038a
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import javax.swing.*; import java.lang.reflect.Array; import java.text.DecimalFormat; import java.util.*; import java.lang.*; import java.io.*; import java.math.*; import java.util.stream.Stream; // Please name your class Main public class Main { static FastScanner fs=new FastScanner(); s...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
771c5756a5fec8232814ded33ebb2752
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
//package codeforces.round766div2; import java.io.*; import java.util.*; import static java.lang.Math.*; public class D { static InputReader in; static PrintWriter out; public static void main(String[] args) { //initReaderPrinter(true); initReaderPrinter(false); //solve(in.nextIn...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
3f980c9214c1c6c4b9303ec6d91153e0
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public final class Main { static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(0, 1), new Pair(1, 0), new Pair(0, -1)}; static int mod = (int) (1e9 + 7);...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
8919c406251115a0f986cbdf95eefa86
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; public class NotAdding_766D { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int max = 0; int n = Integer.parseInt(br.readLine()); String...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
5714febbe8afe7e3804c639ce652b4fc
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
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 sta...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
4a8d92598134b53b56af4e3ee733794e
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { private static final int size = 1000000; //private static final int size = 100; public static int gcd(int a, int b) { return b==0 ? a : gcd(b, a%b); } ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
2402dc41b799a402626c6e427ab2711c
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class D_NotAdding_1900 { public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n = sc.nextInt(); boolean[] isInArray = new boolean[1000001];...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
a7b652974d6e7bdfd969775b299be7df
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
4a8086def5090ccecb7fa5edcd15d474
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class NotAdding { public static PrintWriter out; public static void main(String[] args)throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(br.readLine()); out=new PrintWrit...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
6ab99c7d7955b0fbeb4851090c9e5cb4
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; // cd C:\Users\Lenovo\Desktop\New //ArrayList<Integer> a=new ArrayList<>(); //List<Integer> lis=new ArrayList<>(); //StringBuilder ans = new StringBuilder(); //HashMap<Integer,Integer> map=new HashMap<>(); ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
ef5e18feae966e9a486174d5f61b8fb4
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.BitSet; public class HelloWorld { public static void main(String[] args) { FastScanner fs = new FastScanner(); int n = fs.nextInt(); int ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
09f9cf0e014a10ec469446819262085d
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) // import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.text.CollationElementIterator; im...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
c8ae09b2f6494565ec91f13a58d2c3e9
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; public class ferrisWheel { static PrintWriter pw = new PrintWriter(System.out); static Scanner sc = new Scanner(System.in); public static int gcd(int x,int y) { return x==0?y:gcd(y%x, x); } public static void main(String[] args) throws IOException, Interru...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
802cc9cd8511cae101d30b114c182098
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.Collectors; public class D { static int SIZE = 1000001; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); FastPrintStream out = new FastPrintStream(System.out); int n = sc.ne...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
ce066f5cf403edadfa941dee46077d72
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; public final class A { static PrintWriter out = new PrintWriter(System.out); static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static ArrayList<Integer> g[]; static long ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
bc0496fc823fa08f6626416311627a1f
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class code{ public static int GCD(int a, int b) { if (b == 0) return a; return GCD(b, a % b); } //@SuppressWarnings("unchecked") public static void main(String[] arg) throws IOE...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
d2fa0693baf5055c2e31a86d041e2402
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.lang.reflect.Array; import java.util.Arrays; import java.util.Random; import java.util.Scanner; import jav...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
581b62d1f2967df9b3ed1aaea300c45d
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
// Main Code at the Bottom import java.util.*; import java.io.*; import java.sql.Time; public class Main implements Runnable{ //Fast IO class static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { boolean env=System.getProperty("ONLINE_J...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
8fdb8e0adf112391181ac36b63776d43
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.beans.DesignMode; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.LinkedBl...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
a428ec8065431ebf368da182689e4d82
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static class DSU { private int[] parent; private int totalGroup; public DSU(int n) { parent = new int[n]; totalGroup = n; for (int i = 0; i < n; i++) { p...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
b4d6d06a6edbb0e351725f5901d9cd27
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; public class realfast implements Runnable { private static final int INF = (int) 1e9; long in= (long)Math.pow(10,9); public void solve() throws IOException { ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
4fbac2e86aa2ba72f214e48c69fb31f2
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
// package codeforces; import java.io.*; import java.util.*; public class practice { static FastScanner fs = new FastScanner(); public static final int N = 1000005; public static void main(String[] args) { int t = 1; // t = fs.nextInt(); for(int i=1;i<=t;i++) { solve(t); } } ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
950d4f78ea04f6a69474fa1263ca2e79
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args)throws IOException { FastScanner scan = new FastScanner(); PrintWriter output = new PrintWriter(System.out); int n = scan.nextInt(); int arr[] = scan.readArray(n); int present[] = new int[1000002]; ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
57cd0a1a746cca02b7813fb4e6d6d31d
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; public class Contest_yandexA{ static final int MAXN = (int)1e6; public static void main(String[] args) { Scanner input = new Scanner(System.in); /*int n = input.nextInt(); int k = input.nextInt(); k = k%4; int[] a = new int[n]; for(int i = 0;i<n;i++){ ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
c062579eb02ab45b6369bdbf127141a2
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; /* polyakoff */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int oo = (int) 2e9 + 10; static final long OO = (long) 2e18 + 10; static final int MOD = 998244353; stat...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
1390edc4968de19bdbdd83c3e807077c
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
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.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Sparsh Sanchorawala */ pub...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
3197f12b854683d876c4118fa1d13003
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; public class D1627{ static FastScanner fs = null; public static void main(String[] args) { fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = fs.nextInt(); int N = 1000005; int a[] = new int[n]; boolean vis[] = new boolean[N]; ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
f386ba78603e665552edb96831920437
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class tr1 { static PrintWriter out; static StringBuilder sb; static long mod = 998244353; static Boolean[] memo; static int n, m, id, c; static ArrayList<int[]>[] ad; static HashMap<Integer, Integer>[] going; static long i...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
3b0e2129c6b9446b7fec0af7154d2320
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class problemD { public static void main(String[] args)throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(Syste...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
4ae8592724329b6e49c3b20abdfbd46f
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class CF1627D { private static int gcd(int x, int y) { if (y == 0) { return x; } return gcd(y, x % y); } public static void main(String[] args) throws IOException { ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
7a6ebfa664fbea59844d9c987ce3d7d0
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.util.Map.*; import static java.util.Arrays.*; import static java.util.Collections.*; import static java.lang.System.*; public class Main { public void tq() throws Exception { st=new S...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
d4c16929beca4df5694ef9f2e3b837cd
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; 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.Comparator; import java.util.HashMap; import java.util.Map; import ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
7d4d14a88b627a8a95e35acff6df91f9
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { new MainClass().main(); } } class MainClass { Scanner in = new Scanner(System.in); PrintStream out = System.ou...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
9ac6394754bfd96e00264175988b00be
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { new MainClass().main(); } } class MainClass { Scanner in = new Scanner(System.in); PrintStream out = System.ou...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
08084a515cbb106ef4e6f83059485810
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
/** * check out my youtube channel sh0rkyboy * https://tinyurl.com/zdxe2y4z * I do screencasts, solutions, and other fun stuff in the future */ import java.util.*; import java.io.*; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.Math.max; public class EdD { ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
4e2c78208c803c84c74faae8e67709bb
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.lang.*; import java.util.*; import java.io.*; import java.math.*; public class Main { static void deal(int n,int[] arr) { int max = 0; for(int i=0;i<n;i++) { max = Math.max(arr[i]+1,max); } boolean[] used = new boolean[max]; for(int...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
0689f491715dab06038c6164c82aefd8
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; public class codeforces { public static void main(String[] args) throws Exception { int n=sc.nextInt(); int[]a=new int[1000009]; for(int i=0;i<n;i++) { a[sc.nextInt()]++; } int[]b=new int[1000009]; for(int i=1;i<1000009;i++) { for(int j=i;j<1000009...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
7611efa066da5c23ce2abc23e777539d
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.util.*; import java.io.*; public class D1627 { static final int MAXN = (int) 1e6; public static int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); } public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); ...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
f20d1cdcfc04e4856f18f2aad53f4206
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
/* Setting up my ambitions Check 'em one at a time, yeah, I made it Now it's time for ignition I'm the start, heat it up They follow, burning up a chain reaction, oh-oh-oh Go fire it up, oh, oh, no Assemble the crowd now, now Line 'em up on the ground No leaving anyone behind */ import static java.lang.Math...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
b9c6ff809ef0c6a24fe084a8b422bfb3
train_109.jsonl
1642257300
You have an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array $$$a_i$$$ and $$$a_j$$$ ($$$i \ne j$$$) such that $$$\gcd(a_i, a_j)$$$ is not present in the array, and add $$$\gcd(a_i, a_j)$$$ to the end ...
256 megabytes
import java.io.*; import java.util.*; public class A { static int Max = (int) 1e6 + 1; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); boolean[] active = new boolean[Max + 1]; lo...
Java
["5\n4 20 1 25 30", "3\n6 10 15"]
2 seconds
["3", "4"]
NoteIn the first example, one of the ways to perform maximum number of operations on the array is: Pick $$$i = 1, j= 5$$$ and add $$$\gcd(a_1, a_5) = \gcd(4, 30) = 2$$$ to the array. Pick $$$i = 2, j= 4$$$ and add $$$\gcd(a_2, a_4) = \gcd(20, 25) = 5$$$ to the array. Pick $$$i = 2, j= 5$$$ and add $$$\gcd(a_2, a_5)...
Java 8
standard input
[ "brute force", "dp", "math", "number theory" ]
1a37e42263fdd1cb62e2a18313eed989
The first line consists of a single integer $$$n$$$ ($$$2 \le n \le 10^6$$$). The second line consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$). All $$$a_i$$$ are distinct.
1,900
Output a single line containing one integer — the maximum number of times the operation can be performed on the given array.
standard output
PASSED
a51f5d1be9a432ca9a80b47485b2ca96
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
import java.io.*; import java.util.*; public final class Main { //int 2e8 - long 9e18 static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(0, 1), new Pair(1, 0), new Pair(0, -1)}; static...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
50a7a1df48f2e0731a52137b46bdb3d9
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.lang.invoke.MethodHandles; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.Collections; import java.util.Hash...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
6c89442c6de36a82c3e4d0657ad4529a
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
import java.io.*; import java.util.*; public class A { static long INF = (long) 1e17; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); ...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
e173b715eeec121fd179a36e7ab9c7f7
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
/* Setting up my ambitions Check 'em one at a time, yeah, I made it Now it's time for ignition I'm the start, heat it up They follow, burning up a chain reaction, oh-oh-oh Go fire it up, oh, oh, no Assemble the crowd now, now Line 'em up on the ground No leaving anyone behind */ import static java.lang.Math...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
fc7d37c9af5566213a14fac02ec60703
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
import java.util.*; import java.io.*; ////*************************************************************************** /* public class E_Gardener_and_Tree implements Runnable{ public static void main(String[] args) throws Exception { new Thread(null, new E_Gardener_and_Tree(), "E_Gardener_and_Tr...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
844a892d9457bc0780084c481db387e8
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
import java.io.*; import java.util.*; /* polyakoff */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int oo = (int) 2e9 + 10; static final long OO = (long) 2e18 + 10; static final int MOD = 998244353; stat...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
a00c5a205224d0755dabbecba4113ba5
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
//make sure to make new file! import java.io.*; import java.util.*; public class E766{ public static void main(String[] args)throws IOException{ FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = fs.nextInt(); for(int q = ...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
1e46adee3b3b796a06d72bb42dece365
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run() { for(int q=ni();q>0;q--){ work(); } out.flus...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
e19830762eec12265e0f122b656b2b3e
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
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.PriorityQueue; import java.util.Random; import java.util.StringTokenizer; import java.uti...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
acd5d10fbc57de4f9d417b7b99baffbf
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
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.PriorityQueue; import java.util.Random; import java.util.StringTokenizer; import java.uti...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
570974151fd5d8f71eb98c5ecccfa84d
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.ArrayList; import java.io.InputStream; ...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output
PASSED
4f66e43a78a095036405add690d7ed8c
train_109.jsonl
1642257300
Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount of health.The building consists of $$$n$$$ floors, each with $$$m$$$ rooms ...
256 megabytes
import java.util.*; import java.io.*; public class E1627 { static int n, m, k; static int[] x; static ArrayList<int[]>[] ladders; static final long INF = (long) 1e18, NIL = (long) 2e18; public static int getCeilingLadder(int row, int col) { ArrayList<int[]> myRow = ladders[row]...
Java
["4\n\n5 3 3\n\n5 17 8 1 4\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n6 3 3\n\n5 17 8 1 4 2\n\n1 3 3 3 4\n\n3 1 5 2 5\n\n3 2 5 1 6\n\n5 3 1\n\n5 17 8 1 4\n\n1 3 5 3 100\n\n5 5 5\n\n3 2 3 7 5\n\n3 5 4 2 1\n\n2 2 5 4 5\n\n4 4 5 2 3\n\n1 2 4 2 2\n\n3 3 5 2 4"]
2 seconds
["16\nNO ESCAPE\n-90\n27"]
NoteThe figure for the first test case is in the statement. There are only $$$2$$$ possible paths to $$$(n, m)$$$: Ram travels to $$$(1, 3)$$$, takes the ladder to $$$(3, 3)$$$, travels to $$$(3, 2)$$$, takes the ladder to $$$(5, 1)$$$, travels to $$$(5, 3)$$$ where he finally escapes via helicopter. The health lost ...
Java 8
standard input
[ "data structures", "dp", "implementation", "shortest paths", "two pointers" ]
0c2fd0e84b88d407a3bd583d8879de34
The first line of input contains $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The first line of each test case consists of $$$3$$$ integers $$$n, m, k$$$ ($$$2 \leq n, m \leq 10^5$$$; $$$1 \leq k \leq 10^5$$$) — the number of floors, the number of rooms on each floor and the number of ladders ...
2,200
Output the minimum health Ram loses on the optimal path from $$$(1, 1)$$$ to $$$(n, m)$$$. If Ram cannot escape the clutches of Raghav regardless of the path he takes, output "NO ESCAPE" (all uppercase, without quotes).
standard output