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
59976c2c960b2b6af93e4c0728489f4a
train_110.jsonl
1618839300
Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements.
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Double.parseDouble; import static java.lang.Integer.compare; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.in; import static java.lang.System.out; import static java.util.Arrays.as...
Java
["2\n3\n1 5 4\n2\n100 10000"]
1 second
["YES\nNO"]
NoteIn the first example, the product of the whole array ($$$20$$$) isn't a perfect square.In the second example, all subsequences have a perfect square product.
Java 8
standard input
[ "math", "number theory" ]
33a31edb75c9b0cf3a49ba97ad677632
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$...
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
b2d3ac2ee0ab7f1888ed07777b17c025
train_110.jsonl
1618839300
Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements.
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Double.parseDouble; import static java.lang.Integer.compare; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.in; import static java.lang.System.out; import static java.util.Arrays.asL...
Java
["2\n3\n1 5 4\n2\n100 10000"]
1 second
["YES\nNO"]
NoteIn the first example, the product of the whole array ($$$20$$$) isn't a perfect square.In the second example, all subsequences have a perfect square product.
Java 8
standard input
[ "math", "number theory" ]
33a31edb75c9b0cf3a49ba97ad677632
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$...
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
8dc4e1c1bdde507c8a1d66ec06e8a1c0
train_110.jsonl
1618839300
Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements.
256 megabytes
//package com.govinda.codeforces.codeforces; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * # https://codeforces.com/probl...
Java
["2\n3\n1 5 4\n2\n100 10000"]
1 second
["YES\nNO"]
NoteIn the first example, the product of the whole array ($$$20$$$) isn't a perfect square.In the second example, all subsequences have a perfect square product.
Java 8
standard input
[ "math", "number theory" ]
33a31edb75c9b0cf3a49ba97ad677632
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$...
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
09b5edf8b77119b3dafdfa1518e0f5ca
train_110.jsonl
1618839300
Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int arr[] = new int[n]; for(int i = 0; i < n; i++){ arr[i] = sc.nextInt(); } boolea...
Java
["2\n3\n1 5 4\n2\n100 10000"]
1 second
["YES\nNO"]
NoteIn the first example, the product of the whole array ($$$20$$$) isn't a perfect square.In the second example, all subsequences have a perfect square product.
Java 8
standard input
[ "math", "number theory" ]
33a31edb75c9b0cf3a49ba97ad677632
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$...
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d50fb397258767cc6b7a51fa7f3d4a6f
train_110.jsonl
1618839300
Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import javafx.util.Pair; public class Main { static void sort(int a[]) { Random ran = new Random(); for (int i = 0; i < a.length; i++) { int r = ran.nextInt...
Java
["2\n3\n1 5 4\n2\n100 10000"]
1 second
["YES\nNO"]
NoteIn the first example, the product of the whole array ($$$20$$$) isn't a perfect square.In the second example, all subsequences have a perfect square product.
Java 8
standard input
[ "math", "number theory" ]
33a31edb75c9b0cf3a49ba97ad677632
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$...
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
ba34620e2bf3e24c547c499033b74fb5
train_110.jsonl
1618839300
Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements.
256 megabytes
import java.util.*; import java.io.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try...
Java
["2\n3\n1 5 4\n2\n100 10000"]
1 second
["YES\nNO"]
NoteIn the first example, the product of the whole array ($$$20$$$) isn't a perfect square.In the second example, all subsequences have a perfect square product.
Java 8
standard input
[ "math", "number theory" ]
33a31edb75c9b0cf3a49ba97ad677632
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$...
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d3a77abbfc48f59293b0adfa9fc37c4c
train_110.jsonl
1618839300
Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner o=new Scanner(System.in); int t=o.nextInt(); while(t>0) { int n=o.nextInt(); int ar[]=new int[n]; for(int i=0;i<n;i++) { ar[i]=o.nextInt(); } boolean ps=true; for(int i=0;i<n;i++) { int v=...
Java
["2\n3\n1 5 4\n2\n100 10000"]
1 second
["YES\nNO"]
NoteIn the first example, the product of the whole array ($$$20$$$) isn't a perfect square.In the second example, all subsequences have a perfect square product.
Java 17
standard input
[ "math", "number theory" ]
33a31edb75c9b0cf3a49ba97ad677632
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$...
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
b3e53a53a1209341fe9f92b476254dc1
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { long mod1 = (long) 1e9 + 7; int mod2 = 998244353; public void solve() throws Exception { int n=sc.nextInt(); ArrayList<Integer> a=new A...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
c4acf17e9a5aac9642a29691294ace35
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
// package eround101; import java.util.*; import java.io.*; import java.lang.*; import java.util.StringTokenizer; import java.util.concurrent.TimeUnit; public class C101 { static HritikScanner sc = new HritikScanner(); static PrintWriter pw = new PrintWriter(System.out, true); final static in...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
831ac724af110bfbe817b2e3c8aeb7c1
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList<Integer> ans = new ArrayList<>(); ans.add(1); if( n!= 2) { long prod = 1; for(int ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
adbf05e877967e3a676fbd9144a8f47b
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.stream.IntStream; import java.util.Scanner; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.Buffer...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
48e88333e4b29f7447c583ba8099933f
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) { Scanner io = new Scanner(System.in) ; long n = io.nextLong(); long coprime[] = new long[(int)n]; coprime[1] = 1; long rem = 1; long ans = 1; for(int i=2;i<n;i++) { if(gcd(i,n) == 1){...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
a5c23939ba5ad8ba5c6949f3e8693696
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.util.Set; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
d5a3350fd0c58bb81de94f4aad4a2f0c
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); int n=Integer.parseInt(br.readLine()); ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
3d600399bafe467c52dc73b3f368d6f4
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; public class Main { private static final String NO = "NO"; private...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
6185b4b5016b975dd0ce4df54ffe04b5
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; public class Solution { static long mod=(long)(1e9+7); public static void main(String[] args) { Scanner sc = new Scanner(System.in); // int t = sc.nextInt(); // while(t-->0){ long n=sc.nextInt(); // long k=sc.nextLong(); List<Long> ans=new ArrayList<...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
abdf2b001cb048d20a8910d89cd17bfb
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.Random; import java.util.*; public class ProductModuloN implements Runnable { int[] arr = new int[100005]; void solve() throws IOException { int n = ri...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
83834610b4a9a98abd996c789f7392a4
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; public class GFG { public static int gcd(int n,int m) { if(m==0) return n; else{ return gcd(m,n%m); } } public static void main (String[] args) { Scanner sc=new Scanner(System.in...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
c57541c53549f5bb07fdac6304cc7ea8
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import static java.lang.System.in; import static java.lang.System.out; public class Main{ final static int INF=Integer.MA...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
c49d2c7f28a71c7acb8cb48407686f1a
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); // boolean[] is = sieve(100000); int n = sc.nextInt(); List<Integer> list = new ArrayList<>(); for(int...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
61706d9cf07892e6cf5da3c5ba3da769
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
// have faith in yourself!! /* Naive mistakes in java : --> Arrays.sort(primitive) is O(n^2) --> Never use '=' to compare to Integer data types, instead use 'equals()' --> -4 % 3 = -1, actually it should be 2, so add '+n' to modulo result Stuffs to do when you have no idea how to proceed --> Ma...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
4dc2a69fe1430493fdbf7a80158342d3
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
// have faith in yourself!! /* Naive mistakes in java : --> Arrays.sort(primitive) is O(n^2) --> Never use '=' to compare to Integer data types, instead use 'equals()' --> -4 % 3 = -1, actually it should be 2, so add '+n' to modulo result */ import java.io.*; import java.util.*; public class CodeForc...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
ce0ee64149c0b7899572e6843cf86bb1
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class cp23 { static BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); static int mod = 1000000007; static String toReturn = ""; static int steps = I...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
276f18359f945c382ec17d4fe7a63e71
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; public class Main { static long gcd(long a, long b){ if(b == 0) return a; return gcd(b, a % b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); ArrayList<Integer> arr = new ArrayList<>(); long product...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
73783aa965b25c7ba8b8c0ea3f5d6c3b
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class product1 { public static void main(String[] args) { // System.out.println(gcd(111,221)); //Scanner sc = new Scanner(System.in); FastReader sc = new FastReader(); int n = sc.nextIn...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
f308eb3012930605439644f7fbbc78ac
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * multiplication of all co-prime numbers of n is also co-prime. * */ public class Main { static class FastReader{ ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
3b59f9355f1f2b7955be9b6d57f473d8
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * multiplication of all co-prime numbers of n is also co-prime. */ public class Main { static class FastReader{ ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
33975c1379ffffe3627f4b81043aeef7
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Product1_ModuloN { public static int find_GCD(int a, int b) { if (a == 0) return b; return find_GCD(b % a, a); } public static void main(String[] args) throws IO...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
199cff20a029538ca7cfdb683783ba71
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/*input 8 */ import java.io.*; import java.util.*; public class Main2{ static int ok[] = new int[100005]; public static void main(String[] args) throws Exception { MyScanner scn = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); /* int n ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
6605c0e5f6f3ffef84bacbbdeea86fda
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/*input 8 */ import java.io.*; import java.util.*; public class Main2{ static int ok[] = new int[100005]; public static void main(String[] args) throws Exception { MyScanner scn = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); /* int n ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
eb612f203cb6f2598b3cfd29a1db1ffd
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/*input 8 */ import java.io.*; import java.util.*; public class Main2{ static int ok[] = new int[100005]; public static void main(String[] args) throws Exception { MyScanner scn = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); /* int n ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
4e34a0ce3a1a8271d8a5623f2d7b1848
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
// package com.prituladima; import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; import java.util.stream.IntStream; public final class Template { private void solve() { //https://math.stackexchange.com/questions/441667/the-product-of-integers-relatively-prime-to-n-congru...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
c7123769c1caed5fca0b0806fc668fdc
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; public class ProdMod { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Queue<Integer> fl = new LinkedList<Integer>(); fl.add(1); String ans = "1 "; boolean arr[] = new boolean[n]; ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
197b70e9ce1cf9d84c3825134f1d6e71
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * @Author: * @Date: 2021/4/26 22:27 */ public class Product1ModuloN { public static void main(String[] args) { FastScanner fs = new FastScanner(); int n ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
e861bda57a8421de58c104636b85199a
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; public class Main { public static int gcd(int a, int b){ if(b == 0){ return a; } return gcd(b,a%b); } public static void solve1(int n){ boolean[] arr = new boolean[n]; long prod = 1; for(int i = 1 ; i < n ; i++){ if(gcd(i,n) =...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
88b9ff9ce01a9d8144cc3a06d7bfc120
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.ArrayList; import java.util.StringTokenizer; public class C{ public static void main(String[] args){ FastReader sc = new FastReader(); int n=sc.nextInt(); long pro=...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
ed0aa25a075aa308e1b0bfd10a88864f
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; import java.util.Collections; import java.util.Map.Entry; public class div2_716_C implements Runnable { public void run() { InputReader sc = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int t = 1; wh...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
7676c1e28a66984e60e343d2675df109
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/*input 4 */ import java.util.*; import java.lang.*; import java.io.*; public class Main { static PrintWriter out; static int MOD = 1000000007; static FastReader scan; /*-------- I/O using short named function ---------*/ public static String ns(){return scan.next();} public static int ni(){re...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
0872a4f257703553378ec14b386b7034
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(Syst...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
f05ff9e08b987a004ab37931bf6ea44e
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*;import java.io.*;import java.math.*; public class Main { public static void process()throws IOException { int n=ni(); ArrayList<Integer>l1=new ArrayList<>(); for(int i=1;i<=n-1;i++) { if(gcd(n,i)==1) l1.add(i); } ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
571290bb33dfc74aa8ec64d9cffc6d5e
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/* 5 */ import java.util.*; import java.io.*; public class Main { public static long N; public static ArrayList<Long> relativelyPrime = new ArrayList<Long>(); public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
c7e3f8e9347b82500d6ab7374aa68d92
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; public class prod { static int gcdAlg(int n1, int n2) { if (n2 == 0) { return n1; } return gcdAlg(n2, n1 % n2); } public static void main(String[] ar...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
406f5efc718522f1e1c2ac63cacc4487
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1514c { public static void main(String[] args) throws IOException { int n = ri(); long cur = 1; List<Integer> coprimes = new ArrayList<>(); for (int i...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
fd9b6f6b2d9575277d3b79c170f36d79
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.StringTokenize...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
c42ab8cd779c5662f50b95b7fdb1ed76
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; public class Contest716C { static class InputReader { BufferedReader reader; StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } String next() { // r...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
ae1afee2ed3a998d75f1d2fb419624f4
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedLi...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
5195dab3e2730835617cddb83fa46628
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
//package product1modulon; import java.util.*; import java.io.*; public class product1modulon { public static boolean isCoprime(int a, int b) { for(int i = 2; i <= Math.min(a, b); i++) { if(a % i == 0 && b % i == 0) { return false; } while(a % i == 0) { a /= i; } while(b % i...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
7b9a229a0373deb713917e195011dc3a
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
//https://codeforces.com/contest/1514/problem/C //C. Product 1 Modulo N import java.util.*; import java.io.*; public class CF_1514_C{ static int gcd(int a, int b){ if(b==0) return a; return gcd(b, a%b); } public static void main(String[] args) throws Exception{ BufferedReader br = new Buf...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
a33b08ec4ac6e5c6c82ee2e643bde1a8
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; public class Solve{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); ArrayList<Integer> al=new ArrayList<>(); long p=1; for(int i=1;i<n;i++){ if(gcd(i,n)==1){ p=(p*(long)i...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
b1d7df1474170e36237a5fe5a656f9b0
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) { // Scanner scan = new Scanner(System.in); FastScanner scan = new FastScanner(); long n = scan.nextInt(); List<Long> ls = new ArrayList<>(); long ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
372082282e5dce74d7e20d4ff110d415
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) { new Main().solve(new InputReader(System.in), new PrintWriter(System.out)); } private void solve(InputReader in, PrintWriter pw) { int tt = 1; // ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
a345d8b6744b612e25fbdb07a17dbc24
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class Main { public static int mod = (int)1e9 + 7; // **** -----> Disjoint Set Union(DSU) Start ********** public static int findPar(int node, int[] parent) { if (parent[node] == node) return node; ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
6b8cb719fa88c1ab7981d2956420c3e5
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.lang.Math; import java.util.*; public final class Codechef { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static BufferedWriter bw = new BufferedWriter( new OutputStreamWriter(System.out) ); static StringTokenizer st; ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
2135a65e4e9dde1040b0ac59c3e6455f
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; public class practise { static boolean multipleTC = false; final static int Mod = 1000000007; final static int Mod2 = 998244353; final double PI = 3.14159265358979323846; int MAX = 1000000007; void pre() throws Exception { } void DFSUtil(int v, boolean[] v...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
067c4eb5064228f4767d6895da0818b9
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; import java.util.function.BiFunction; import java.util.function.Function; public class Main { static BiF...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
9e4e3186b4a4cf090d678639f0efe7db
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main{ public static void main(String[] args){ Solve Flamboyance=new Solve(); } } class Solve{ int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); } Solve(){ ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
459cfd149509b0f14c229d8d67eb9e0a
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import javax.swing.event.TreeSelectionEvent; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
16891ba8081056ce4487550a0c6374d3
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; public class Div21514C { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); long n = I...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
ec9a0e1978b68c37eac82ab9730f4975
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/* TASK: template LANG: JAVA */ import java.io.*; import java.lang.*; import java.util.*; public class C1514 { public static void main(String[] args) throws IOException{ StringBuffer ans = new StringBuffer(); StringTokenizer st; BufferedReader f = new BufferedReader(new Inp...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
e3f2fd3db0210240455d8e204b9a33dd
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
// The product of all the numbers co-prime with n is also co-prime with n. // If (product%n)!=1 , then we remove (product%n) from our list or the last element of the list if the list is sorted in asc order. import java.io.*; import java.util.*; public class ProductOneModuloN { static long gcd(long a, long b) ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
ee60b0d27f0680745786b22ebe9e43cf
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; public class cf1519_Div2_C { public static void main(String args[]) throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); long p = 1; boolean[] valid = new boolean[n]; int c...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
656caf71e0d297bd271d115bdecdee7d
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
//import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.Input...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
c0ca2a8c0ff70e14169dd0ec13a21a3b
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Problem_3 { public static void main(String args[]) { // System.out.println(getGcd(98765, 92077)); Fast...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
e071598e9ff746d79671ef94cd6dc5d6
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
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 First { public static void main(String[] args) { InputStream inputStream = System.in...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
4b0c2947c3f67bd8bcf7e4c2f2b35c6d
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; public class Solve { static final int MOD = 1000000007; public static void main(String[] args) { Reader in = new Reader(); PrintWriter out = new PrintWriter(System.out); int t = 1; while (t-- > 0) solve(in, out); ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
39caadbb94f58d41b877a4c0aaa0a9ce
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); long product = 1; List<Integer> ans = new ArrayList<>(); for (int i...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
36b8321ad734b59ca67fcb9fda0acdc5
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; public class Sol{ public static void main(String []args){ FastReader sc=new FastReader(System.in); int t=1; while(t-->0){ int n=sc.nextInt(); StringBuilder s1=new StringBuilder();int j=0; for(int i=1;i<=n-1;i++){if(gcd(n,i)==1){j++;}} int res[]=new int[j];j=0; for(in...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
c52a9eed69e58589d855ab77073b607e
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
//package contest19april; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class C { static class FastReader { BufferedReader br; StringTokenizer st; public FastR...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
79456e87b1f68354698869dd54bf3cb3
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class mod { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int n; n=sc.nextInt(); ArrayList<Integer> list = new ArrayList<>(); ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
061d92e4e8c9c026fd74791311188112
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.stream.Collectors; /** * Built using CHelper plug-in * Actual...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
5c23d053e8554bd90678179829d52afe
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.math.*; import java.util.*; import java.io.*; public class main { static Map<String,Integer> map=new HashMap<>(); public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter pw = new PrintWriter(System.out); final int m...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
2fe88b04886749aa2d19257ed47793a0
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.*; public class C { static class FastScanner { BufferedReader br; StringTokenizer st; public FastSc...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
6e8c697b12ab2837fd04444d9ca03459
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/** * Created by Himanshu **/ import java.util.*; import java.io.*; import java.math.*; public class C1514 { public static void main(String[] args) throws IOException { PrintWriter out = new PrintWriter(System.out); Reader s = new Reader(); int n = s.i(); ArrayList<I...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
aa8ac074ca68ace7a606d3b277ef66c3
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; public class C_Rnd716_Product_faster { static int n; static boolean debug = false; public static void main(String[] args) throw...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
715f1a8fa73553a5efab12f12bf5dab1
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public final class C { public static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } priv...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
77de5d60ff0ec99d75f7d3c838a4e3ed
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; public class product1ModuloN { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); List<Long> al = new ArrayList<>(); long p = (long)1; for(int i =1; i<n; i++) { if(GCD(i, n)==1) { al...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
d857b0d4891ca8b1dffd9365757b2a46
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; public class CF1514C { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader (new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); ArrayList<Integer> A = new ArrayList<>(); ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
7f3cef3251bd1d149677738cc1653dd6
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int n = Integer.parseInt(br.readLine()); ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
7263d5da4e940f3d818d827c1dc0fac7
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
//Utilities import java.io.*; import java.util.*; public class a { static int t; static int n; static int[] fac, inv; static ArrayList<Integer> res; static boolean[] vis; public static void main(String[] args) throws IOException { t = 1; while (t-- > 0) { n = in.iscan(); res = new A...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
0822b074f5188a8a1bf0acbcbda3c09e
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; public class prod1modn { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); StringTokenize...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
00b5c14845a802ed16a0a1b2c2462225
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
//package com.company; import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main{ static boolean[] primecheck; static ArrayList<Integer>[] adj; static int[] vis; static int[] parent = new int[101]; static int[] rank = new int[101]; static int mod = (...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
e8f51d2fe51d9412ad6e8c32cd273a6a
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class Main { static class Pair { long l; char c; public Pair(long l,char c) { this.l = l; this.c=c; } public String toString() { return l +" "+c; ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
8d19ed8e14d248a36005f3ba05ee3d5b
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
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 javax.management.InstanceNotFoundException...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
903e6b7a84d39b42bf79ddea116aa9ee
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; public class product1 { static class FastIO extends PrintWriter { private InputStream stream; private byte[] buf = new byte[1 << 16]; private int curChar; private int numChars; // standard input public FastIO() { this(System.in,...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
8029c548ad2d889f9e2b7d76a1dcc44c
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
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.*; //update this bad boi too public class Main{ static int mod = (int) (Math.pow(10, 9)+7); static final int dx...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
8cb8f83d4356bc5a2b25ed0de027d4a8
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
// \(≧▽≦)/ 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) { run_case(); ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
ed88171089c229ca4b264f74dd0e894b
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
//package Practise; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class Product1ModuloN { public static void main(String args[]) { FastScanner fs=new FastScanner(); ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
a2d595abeeb65fb1135f3afc04cda302
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; public class Practice { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextInt(); long product = 1; ArrayList<Long> set = new ArrayList<>(); set.add(1L); for(long i=2;i<n;i++){ long ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
451d8f98d6d91960404b3ff1cc529a75
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long prod = 1; List<Long> output = new ArrayList<>(); for(long k = 1; k < n; k++) { if(gcd(n,k) == 1) { ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
485822625757012204aad0dcc94c24b8
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
/* JAI MATA DI */ import java.util.*; //import javax.print.attribute.HashAttributeSet; import java.io.*; import java.math.BigInteger; import java.sql.Array; public class CP { static class FR{ BufferedReader br; StringTokenizer st; public FR() { br = new BufferedReader(new Input...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
7cc4a32c6787c1db22e2d662229ec416
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; public class Main { private static final String NO = "NO"; private...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
2df5014949e60deb207cfb3f2c97d9ce
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; public class MyClass { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
26669e3a77ae66028bb9808a3b0c3928
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; import java.util.Map.Entry; public class Main{ static final int inf=Integer.MAX_VALUE; static final int mod=(int)1e9+7; //divide into cases, brute force //sort, greedy, binary search //transform into graph static void solve(Reader in, Writer out){ ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
3bb5dfa46fc23ade79afc39f0cf18d72
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.lang.*; public final class CodeForces { static FastScanner scan = new FastScanner(); static StringBuffer output = new StringBuffer(); static final long MOD = (long) (1e9 + 7); public static void main(String[] args) throws IOException { int t = 1; ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
63f05dc0796385897d0555ea2aba64b7
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
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.StringTokenizer; import java.io.*; public class Product1Mod { private static class MyScanner { BufferedReader br; StringTokenizer st; ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
5c85ec38e951900ec31c99e7a4944e65
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.*; import java.io.*; public class Main { static InputReader scn = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] HastaLaVistaLa) { // Running Number Of TestCases (t) int t = 1; while(t-- > 0) ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
39071726dcb42be67bd1a5c365a3f4f9
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class A{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long MOD = 1000000007; int t = 1; outer: for(int z=0; z<t; z++) { int n = sc.nextInt(); ArrayList<Integer> list = new ArrayList<>(); long va...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
7ec4aa32f4c0a966a5e6234805dcb40c
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Codeforces { static FastScanner sc; static PrintWriter out; static int mod = (int) (1e9+7); public static void main(String[] args){ ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
95a69ec31658b5ff5e84b9ccf1f19c74
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n=scan.nextInt(); long ans=1; List<Integer>list=new ArrayList<>(); for(int i=1;i<n;i++)...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output
PASSED
b4256e6d2794b97081c53a20bef14d36
train_110.jsonl
1618839300
Now you get Baby Ehab's first words: "Given an integer $$$n$$$, find the longest subsequence of $$$[1,2, \ldots, n-1]$$$ whose product is $$$1$$$ modulo $$$n$$$." Please solve the problem.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly all) elem...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Main { static long mod=(long) Math.pow(10,9) + 7; public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); StringBuilder fout = new StringBuilder(); int t =1; ...
Java
["5", "8"]
1 second
["3\n1 2 3", "4\n1 3 5 7"]
NoteIn the first example, the product of the elements is $$$6$$$ which is congruent to $$$1$$$ modulo $$$5$$$. The only longer subsequence is $$$[1,2,3,4]$$$. Its product is $$$24$$$ which is congruent to $$$4$$$ modulo $$$5$$$. Hence, the answer is $$$[1,2,3]$$$.
Java 11
standard input
[ "greedy", "number theory" ]
d55afdb4a83aebdfce5a62e4ec934adb
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).
1,600
The first line should contain a single integer, the length of the longest subsequence. The second line should contain the elements of the subsequence, in increasing order. If there are multiple solutions, you can print any.
standard output