exec_outcome
stringclasses
1 value
code_uid
stringlengths
32
32
file_name
stringclasses
111 values
prob_desc_created_at
stringlengths
10
10
prob_desc_description
stringlengths
63
3.8k
prob_desc_memory_limit
stringclasses
18 values
source_code
stringlengths
117
65.5k
lang_cluster
stringclasses
1 value
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_time_limit
stringclasses
27 values
prob_desc_sample_outputs
stringlengths
2
796
prob_desc_notes
stringlengths
4
3k
lang
stringclasses
5 values
prob_desc_input_from
stringclasses
3 values
tags
sequencelengths
0
11
src_uid
stringlengths
32
32
prob_desc_input_spec
stringlengths
28
2.37k
difficulty
int64
-1
3.5k
prob_desc_output_spec
stringlengths
17
1.47k
prob_desc_output_to
stringclasses
3 values
hidden_unit_tests
stringclasses
1 value
PASSED
d4bcefb7b4c5261a560f94b98613d27a
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 Cf { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int t=sc.nextInt(); while(t--!=0) { int n=sc.nextInt(); boolean found=false; int i=0; for( ;i<n;i++) { int a=sc.nextInt(); if(!issqrt(a)) { found=true; } } if(found) { System.out.println("YES"); } else { System.out.println("NO"); } } } static boolean issqrt(int n) { int a=(int)Math.sqrt((double)n); if(a==0)return false; if(n%a==0) { n/=a; if(a==n)return true; } return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
ddaf9a59af55c1baca2c35792f899ed6
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 Cf { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int t=sc.nextInt(); while(t--!=0) { int n=sc.nextInt(); boolean found=false; int sum=1; int i=0; for( ;i<n;i++) { int a=sc.nextInt(); sum*=a; if(!issqrt(a)) { found=true; } } if(found) { System.out.println("YES"); } else { System.out.println("NO"); } } } static boolean issqrt(int n) { int a=(int)Math.sqrt((double)n); if(a==0)return false; if(n%a==0) { n/=a; if(a==n)return true; } return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
03521f7aebf6785841ccf55d8da783e5
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) { // write your code here 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(); } String ans="NO"; for(int x:arr) { if(checkPerfectSquare(x)==false) { ans="YES"; // break; } } System.out.println(ans); } } static boolean checkPerfectSquare(int number) { //calculating the square root of the given number double sqrt=Math.sqrt(number); //finds the floor value of the square root and comparing it with zero return ((sqrt - Math.floor(sqrt)) == 0); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
91f278079a570d4cb2cea1d7e70c5660
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.lang.*; import java.util.*; public class A1514 { public static void main(String[] args) throws IOException{ StringBuffer ans = new StringBuffer(); StringTokenizer st; BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(f.readLine()); int t = Integer.parseInt(st.nextToken()); for(int i = 0; i < t; i++){ st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken()); st = new StringTokenizer(f.readLine()); int[] arr = new int[n]; for(int x = 0; x < n; x++){ arr[x] = Integer.parseInt(st.nextToken()); } boolean check = false; for(int x = 0; x < n; x++){ long chk = arr[x]; long r = (long)Math.sqrt(chk); if(Math.sqrt(chk) - r > .0000000000000000001){ check = true; } for(int y = x+1; y < n; y++){ chk = arr[x]; chk*=arr[y]; r = (long)Math.sqrt(chk); if(Math.sqrt(chk) - r > .0000000000000000001){ check = true; } } } if(check) ans.append("YES"); else ans.append("NO"); ans.append("\n"); } f.close(); System.out.println(ans); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
7852ab4dc23052adc859f7ed322c3141
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 CodeForces_716 { public static void main(String[] args){ Scanner in=new Scanner(System.in); int tt=in.nextInt(); while (tt-->0){ int n=in.nextInt(); long[] a=new long[n]; for(int i=0;i<n;i++){ a[i]=in.nextLong(); } boolean check=true; for(int i=0;i<n;i++){ if(!checkPerfectSquare((double) (a[i]))){ check =false; break; } } if(!check) System.out.println("YES"); else System.out.println("NO"); } } static boolean isPerfectSquare(double x) { if (x >= 0) { double sr = Math.sqrt(x); return ((sr * sr) == x); } return false; } static boolean checkPerfectSquare(double number) { double sqrt=Math.sqrt(number); return ((sqrt - Math.floor(sqrt)) == 0); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
26b30b9ad5e70b62cc0b32d60164c306
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 SolutionA{ public static void main(String[] args) throws Exception{ Fast sc=new Fast(); StringBuilder sb=new StringBuilder(); int t=sc.nextInt(); HashSet<Double> al=new HashSet<>(); while(t-->0){ int n=sc.nextInt(); long[] ar=new long[n]; for(int i=0;i<n;i++){ ar[i]=sc.nextLong(); } boolean ok=false; for(int i=0;i<n;i++){ double z=Math.sqrt(ar[i]); if(z!=(double)((long)z)) ok=true; } if(ok)System.out.println("YES"); else System.out.println("NO"); } } static void ReverSort(int[] ar){ ArrayList<Integer> al=new ArrayList<>(); for(int i=0;i<ar.length;i++){ al.add(ar[i]); } Collections.sort(al); int j=0; for(int i=al.size()-1;i>=0;i--){ ar[j]=al.get(i); j++; } } static void Sort(int[] ar){ ArrayList<Integer> al=new ArrayList<>(); for(int i=0;i<ar.length;i++){ al.add(ar[i]); } Collections.sort(al); int j=0; for(int i=0;i<al.size();i++){ ar[j]=al.get(i); j++; } } static int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b); } } class Pair{ int x, y; Pair(int x,int y){ this.x=x; this.y=y; } } class SortPair implements Comparator<Pair>{ public int compare(Pair p1, Pair p2){ return p1.y-p2.y; } } class Fast{ BufferedReader br; StringTokenizer st; public Fast(){ br=new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt(){ return Integer.parseInt(next()); } long nextLong(){ return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } }
Java
["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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d3da5c3487add77da9be89ce7c925092
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 scn = new Scanner(System.in); int t = scn.nextInt(); while(t>0){ int n= scn.nextInt(); int[] arr = new int[n]; for(int i = 0;i<n;i++){ arr[i]=scn.nextInt(); } int flag = 0; for(int i = 0;i<n;i++){ if(!isperfectsquar(arr[i])){ flag =1; } } if(flag==0){ System.out.println("NO"); } else if(flag==1){ System.out.println("YES"); } t--; } } public static boolean isperfectsquar(int num){ if(num >=0){ int x = (int)Math.sqrt(num); return (x*x == num); } return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f3e444b0b7eed97480c0d60324b7ba6b
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.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Random; import java.util.StringTokenizer; /* */ public class Solution { public static void main(String[] args) { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int T = fs.nextInt(); HashMap<Long, Long> map = new HashMap<Long, Long>(); for (int i = 0; i <= 10000; i++) { map.put((long) (i * i), (long) i); } for (int tt = 0; tt < T; tt++) { int n = fs.nextInt(); int arr[] = new int[n]; boolean sq = true; for (int i = 0; i < n; i++) { arr[i] = fs.nextInt(); if (!map.containsKey((long) arr[i])) { sq = false; } } if (sq) System.out.println("NO"); else System.out.println("YES"); } } static boolean isPrime(int n) { if (n == 2) { return true; } for (int i = 2; i <= Math.ceil(Math.sqrt(n)); i++) { if (n % i == 0) { return false; } } return true; } static long gcd(long a, long b) { if (b > a) { return gcd(b, a); } if (b == 0) { return a; } return gcd(b, a % b); } // Function to find gcd of array of // numbers static long findGCD(long arr[], int n) { long result = 0; for (long element : arr) { result = gcd(result, element); if (result == 1) { return 1; } } return result; } static int isSubstring( String s1, String s2) { int M = s1.length(); int N = s2.length(); /* A loop to slide pat[] one by one */ for (int i = 0; i <= N - M; i++) { int j; /* * For current index i, check for * pattern match */ for (j = 0; j < M; j++) if (s2.charAt(i + j) != s1.charAt(j)) break; if (j == M) return i; } return -1; } static boolean possible(int[] a, int mid) { int n = a.length; long[] clone = new long[n]; for (int i = 0; i < n; i++) clone[i] = a[i]; for (int i = n - 1; i >= 2; i--) { if (clone[i] < mid) return false; long toGive = (clone[i] - mid) / 3 * 3; toGive = Math.min(toGive, a[i]); clone[i] -= toGive; clone[i - 1] += toGive / 3; clone[i - 2] += toGive / 3 * 2; } if (clone[0] < mid || clone[1] < mid) return false; return true; } static final Random random = new Random(); static final int mod = 1_000_000_007; static int[] ruffleSort(int[] a) { int n = a.length;// shuffle, then sort for (int i = 0; i < n; i++) { int oi = random.nextInt(n), temp = a[oi]; a[oi] = a[i]; a[i] = temp; } Arrays.sort(a); return a; } static long add(long a, long b) { return (a + b) % mod; } static long sub(long a, long b) { return ((a - b) % mod + mod) % mod; } static long mul(long a, long b) { return (a * b) % mod; } static long exp(long base, long exp) { if (exp == 0) return 1; long half = exp(base, exp / 2); if (exp % 2 == 0) return mul(half, half); return mul(half, mul(half, base)); } static long[] factorials = new long[2_000_001]; static long[] invFactorials = new long[2_000_001]; static void precompFacts() { factorials[0] = invFactorials[0] = 1; for (int i = 1; i < factorials.length; i++) factorials[i] = mul(factorials[i - 1], i); invFactorials[factorials.length - 1] = exp(factorials[factorials.length - 1], mod - 2); for (int i = invFactorials.length - 2; i >= 0; i--) invFactorials[i] = mul(invFactorials[i + 1], i + 1); } static long nCk(int n, int k) { return mul(factorials[n], mul(invFactorials[k], invFactorials[n - k])); } static void sort(int[] a) { ArrayList<Integer> l = new ArrayList<>(); for (int i : a) l.add(i); Collections.sort(l); for (int i = 0; i < a.length; i++) a[i] = l.get(i); } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
957984da3b4359e174c74e686cf6a734
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[] srgs) { 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(); } PerfectlyImperfectArray(arr); } } public static void PerfectlyImperfectArray(int[] arr){ for (int i=0;i<arr.length;i++){ double x=arr[i]; double y=Math.sqrt(x); if (y-(int)y!=0){ System.out.println("YES"); return; } } System.out.println("NO"); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
20a2f12a772206768dc9bb1fe34e93e0
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.util.regex.*; import java.lang.*; import java.io.*; public class rough{ static BufferedReader br; /*static int[][] dir = {{1,0}, {0,1}, {-1,0}, {0,-1}}; static class Node{ int n, f; Node(int n, int f){ this.n = n; this.f = f; } } public static class comp implements Comparator<Node>{ public int compare(Node a, Node b){ return b.f-a.f; } }*/ /*static int comp = 0; public static int find(int[] parent, int x){ if (!(x>=0 && x<parent.length)){ return -1; } if (parent[x] < 0){ return x; }else{ return (parent[x]=find(parent, parent[x])); } } public static void union(int[] parent, int n1, int n2){ int r1 = find(parent, n1), r2 = find(parent, n2); if (r1 == r2) return; comp--; if (parent[r1] <= parent[r2]){ parent[r1] += parent[r2]; parent[r2] = r1; }else{ parent[r2] += parent[r1]; parent[r1] = r2; } }*/ /*static HashMap<Long, HashMap<Long, Long>> dp; static long rec(long[] diff, List<Integer> al, long comp, long k, long x){ //System.out.println("```"); //System.out.println(comp+" "+k+" "+x); if (k<0){ return comp+1; } if (al.size() == 0 || k == 0){ return comp; } if (hm.containsKey(comp) && hm.get(comp).containsKey(k)){ return hm.get(comp).get(k); } int idx = al.get(0); al.remove(0); long r = (Math.min(rec(diff, al, comp-1, k-((int)Math.ceil((double)diff[idx]/x)-1), x), rec(diff, al, comp, k, x))); al.add(0, idx); if (hm.containsKey(comp)){ if (hm.get(comp).containsKey(k)){ long tmp = hm.get(comp).get(k); tmp = Math.min(tmp, r); hm.get(comp).put(k, tmp); }else{ hm.get(comp).put(k, r); } }else{ HashMap<Long, Long> tmp = new HashMap<>(); tmp.put(k, r); hm.put(comp, tmp); } return hm.get(comp).get(k); //return r; }*/ public static boolean solve() throws IOException{ int n = Integer.parseInt(br.readLine().trim()); String[] tmp = br.readLine().trim().split(" "); int[] arr = new int[n]; boolean flag = false; for (int i=0 ; i<n ; i++){ arr[i] = Integer.parseInt(tmp[i]); double sqrt = Math.sqrt(arr[i]); if (sqrt-Math.floor(sqrt) != 0){ return true; } } return false; } public static void main(String args[]) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine().trim()); while (t-->0){ boolean ans = solve(); if (ans) System.out.println("YES"); else System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
86c6d032fef5a9dc9523f9bc87106015
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 { public static void main(String args[]) throws IOException { Scanner input = new Scanner(System.in); int n = input.nextInt(); int sum=0; for (int i=0;i<n;i++){ int number= input.nextInt(); sum=0; for (int j=0;j<number;j++){ int numbers= input.nextInt(); //System.out.println("numbers: "+numbers); if (Math.round(Math.sqrt(numbers))!=Math.sqrt(numbers)){ sum=sum+1; } } if (sum==0){ System.out.println("NO"); }else { System.out.println("YES"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
3c4b4379f85e2c190c72a2e0e39f739d
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.lang.*; import java.io.*; public class Codechef { public static void main(String [] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); int a[] = new int[n]; String s = ""; for(int i=0;i<n;i++) { int product = 1; a[i] = sc.nextInt(); product *= a[i]; long c1 = (long)Math.sqrt(product); double c2 = (double)c1; double c3 = (double)Math.sqrt(product); if(c1!=c3) s+="."; } if(s.contains(".")) System.out.println("YES"); else System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
c8ba7d1d5d8fd3288f57461bc5852d49
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(); long a[] = new long[n]; long product = 1; String s = ""; for(int i=0;i<n;i++) { product = 1; a[i] = sc.nextLong(); product=product*a[i]; double check1 = (double)Math.pow(product,0.5); long test = (long)Math.pow(product,0.5); double check2 = (double)test; if(check1!=check2) s+="present"; } if(s.contains("present")) System.out.println("YES"); else System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
b9552e45ff425cea0e5fb7fd7ddfabec
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.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { FastReader in = new FastReader(); PrintWriter pw = new PrintWriter(System.out); int t = in.nextInt(); while(t-- > 0) { int n = in.nextInt(); int[] arr = new int[n]; for(int i = 0; i < n; i++) { arr[i] = in.nextInt(); } boolean ans = false; for(int i = 0; i < n; i++) { if(Math.sqrt(arr[i]) % 1 != 0) { ans = true; break; } } pw.println(ans ? "YES" : "NO"); } pw.close(); } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while(st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch(IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch(IOException e) { e.printStackTrace(); } return str; } } }
Java
["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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
31188ed2812049fb9ab009df194434ae
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 int mod=(int)1e9+7; public static void main(String[] args) { Scanner scn=new Scanner(System.in); int t=scn.nextInt(); while(t-- >0){ int n=scn.nextInt(); boolean ans=true; while(n-->0) { int val=scn.nextInt(); double sqrt=Math.sqrt(val); if(sqrt!=(int)sqrt) { ans=false; } } if(ans) { System.out.println("NO"); }else { System.out.println("YES"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
7afbedfe895b95ff4313bc886c1643ba
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 in =new Scanner(System.in); int t=in.nextInt(); while(t>0){ int a=in.nextInt(),s=0; int arr[]=new int[a]; for(int i=0;i<a;i++){ arr[i]=in.nextInt(); int ss=(int)(Math.sqrt(arr[i])); if(Math.sqrt(arr[i])-ss==0)s++; } if(s==a) System.out.println("NO"); else System.out.println("YES"); t--; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
4d907e8cba712910019dda30f379504a
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(); double arr[] = new double[n]; int pro = 1; double num = 0; for(int i=0;i<n;i++) { arr[i] = sc.nextDouble(); } if(check(arr)) { System.out.println("NO"); }else { System.out.println("YES"); } } } public static boolean check(double arr[]) { int n =arr.length; for(int i=0;i<n;i++) { if(!check(arr[i])) { return false; } } return true; } public static boolean check(double num) { double sq = Math.sqrt(num); return (sq-Math.floor(sq)==0); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
0955c020c65b89f62937f9e9b0ab4a4e
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 Test1 { public static boolean isPerfectSquare(int n){ boolean res=false; double sqrt=Math.sqrt(n); return ((sqrt - Math.floor(sqrt)) == 0); } public static void main(String[] args) { Scanner scan=new Scanner(System.in); int t=scan.nextInt(); while(t-->0){ int n=scan.nextInt(); int[]a=new int[n]; for(int i=0;i<n;i++) { a[i] = scan.nextInt(); } int flag=0; for(int i=0;i<a.length;i++){ if(!isPerfectSquare(a[i])){ System.out.println("YES"); flag=1; break; } } if(flag!=1) System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
c502962010288c63e0160bf538e1b191
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) { // write your code here Scanner input = new Scanner(System.in); int numberOfTestCases = input.nextInt(); for (int x = 0; x < numberOfTestCases; x++){ int arraySize = input.nextInt(); int arr[] = new int[arraySize]; for (int i = 0; i < arraySize; i++){ arr[i] = input.nextInt(); } imperfectArray(arr); } } static void imperfectArray(int[] arr){ int l = arr.length; for (int j = 0; j < l; j++){ int p = 1; if (arr[j] == 0 || arr[j] == 1) continue; p *= arr[j]; double root = Math.sqrt((double) p); if (root != Math.floor(root)) { System.out.println("YES"); return; } } System.out.println("NO"); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
03ddd58155c707d2eb53f11b75ebf06b
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.math.*; import java.util.*; // @author : Dinosparton public class test { static class Pair{ long x; long y; Pair(long x,long y){ this.x = x; this.y = y; } } static class Compare { void compare(Pair arr[], int n) { // Comparator to sort the pair according to second element Arrays.sort(arr, new Comparator<Pair>() { @Override public int compare(Pair p1, Pair p2) { return (int)(p1.x - p2.x); } }); // for (int i = 0; i < n; i++) { // System.out.print(arr[i].x + " " + arr[i].y + " "); // } // System.out.println(); } } static class Scanner { BufferedReader br; StringTokenizer st; public Scanner() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public static void main(String args[]) throws Exception { Scanner sc = new Scanner(); StringBuffer ans = new StringBuffer(); boolean[] prime = new boolean[100001]; for(int i = 1; i <= 100; i++) { prime[i * i] = true; } int tc = sc.nextInt(); while(tc-->0) { int n = sc.nextInt(); boolean ok = false; for(int i=0;i<n;i++) { int x = sc.nextInt(); if(!prime[x]) ok = true; } if(ok) ans.append("YES"+"\n"); else ans.append("NO"+"\n"); } System.out.println(ans); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
2216da952a717ab2d802f48ea2fb8102
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 a2oj { static FastReader sc; static PrintWriter out; static int mod = 1000000007; public static void main(String[] args) throws IOException { if (System.getProperty("ONLINE_JUDGE") == null) { File f1 = new File("input.txt"); File f2 = new File("output.txt"); Reader r = new FileReader(f1); sc = new FastReader(r); out = new PrintWriter(f2); double prev = System.currentTimeMillis(); solve(); out.println("\n\nExecuted in : " + ((System.currentTimeMillis() - prev) / 1e3) + " sec"); } else { sc = new FastReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); } out.flush(); out.close(); } static void solve() { int t = sc.nextInt(); StringBuilder ans = new StringBuilder(""); while (t-- > 0) { int n = sc.nextInt(); long[] arr = sc.readArrayL(n); boolean z = false; for (int i = 0; i < n; i++) { if (!isPerfectSquare(arr[i])) { z = true; break; } } if (z) { ans.append("YES\n"); } else { ans.append("NO\n"); } } out.println(ans); } static long modInverse(long a) { long g = gcd(a, mod); if (g != 1) return -1; else { return modPower(a, mod - 2L); } } static long modPower(long x, long y) { long res = 1; x = x % mod; if (x == 0) return 0; while (y > 0) { if ((y & 1) != 0) res = (res * x) % mod; y = y >> 1; x = (x * x) % mod; } return res; } static long gcd(long a, long b) { if (b == 0) return a; else return gcd(b, a % b); } static boolean isPerfectSquare(long x) { long sqrt = (long) Math.sqrt(x); return (sqrt * sqrt) == x; } public static int digitsCount(long x) { return (int) Math.floor(Math.log10(x)) + 1; } public static boolean isPowerTwo(long n) { return (n & n - 1) == 0; } static void sieve(boolean[] prime, int n) { // Sieve Of Eratosthenes for (int i = 1; i <= n; i++) { prime[i] = true; } for (int i = 2; i * i <= n; i++) { if (prime[i]) { for (int j = 2; i * j <= n; j++) { prime[i * j] = false; } } } } static long nCr(int n, int r) { // Combinations if (n < r) return 0; if (r > n - r) { // because nCr(n, r) == nCr(n, n - r) r = n - r; } long ans = 1L; for (int i = 0; i < r; i++) { ans *= (n - i); ans /= (i + 1); } return ans; } static long catalan(int n) { // n-th Catalan Number long c = nCr(2 * n, n); return c / (n + 1); } static class Pair implements Comparable<Pair> { // Pair Class int x; int y; public Pair(int x, int y) { this.x = x; this.y = y; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Pair)) { return false; } Pair pair = (Pair) o; if (x != pair.x) { return false; } if (y != pair.y) { return false; } return true; } @Override public int hashCode() { long result = x; result = 31 * result + y; return (int) result; } @Override public int compareTo(Pair o) { return (int) (this.x - o.x); } } static class Trip { // Triplet Class long x; long y; long z; Trip(long x, long y, long z) { this.x = x; this.y = y; this.z = z; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Trip)) { return false; } Trip trip = (Trip) o; if (x != trip.x) { return false; } if (y != trip.y) { return false; } if (z != trip.z) { return false; } return true; } @Override public int hashCode() { long result = 62 * x + 31 * y + z; return (int) result; } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(Reader r) { br = new BufferedReader(r); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } int[] readArrayI(int n) { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } return arr; } long[] readArrayL(int n) { long[] arr = new long[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextLong(); } return arr; } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } /* * ASCII Range--->(A-Z)--->[65,90]<<::>>(a-z)--->[97,122] */ /******************************************************************************************************************/ static void printArray(int[] arr) { out.print("["); for (int i = 0; i < arr.length; i++) { if (i < arr.length - 1) out.print(arr[i] + ","); else out.print(arr[i]); } out.print("]"); out.println(); } static void printArray(long[] arr) { out.print("["); for (int i = 0; i < arr.length; i++) { if (i < arr.length - 1) out.print(arr[i] + ","); else out.print(arr[i]); } out.print("]"); out.println(); } static void printArray(double[] arr) { out.print("["); for (int i = 0; i < arr.length; i++) { if (i < arr.length - 1) out.print(arr[i] + ","); else out.print(arr[i]); } out.print("]"); out.println(); } /**********************************************************************************************************************/ }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
6ff92cd0924264e6e7db56fdebe18d02
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; import java.io.*; import java.util.*; import java.util.Stack; import java.util.HashMap; import java.util.Map; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.StringTokenizer; import java.io.Reader; import java.util.Collections; import java.lang.StringBuilder; import java.util.Queue; import java.util.List; import java.text.DecimalFormat; import java.math.BigDecimal; import java.math.BigInteger; public class Codeforces2{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int tests = scan.nextInt(); for(int i=0; i<tests;i++) { int num = scan.nextInt(); boolean perfect=true; for(int j=0;j<num;j++) { double x = scan.nextDouble(); double y = (Math.sqrt(x)); double noDecimals = y-Math.floor(y); if(perfect == true && noDecimals != 0) perfect = false; } if(perfect==true) { System.out.println("NO"); } else System.out.println("YES"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
4d601f7a23f53a2213327d4025aca7fb
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 { public static void main(String[] args)throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0) { String p=br.readLine(); String s[]=p.split(" "); String arr=br.readLine(); String ar[]=arr.split(" "); int n=Integer.parseInt(s[0]); int a[]=new int[n]; int c=1; int m=0; for(int i=0;i<n;i++) { a[i]=Integer.parseInt(ar[i]); int h=(int)(Math.sqrt(a[i])); if(((h*h)!=a[i]) && a[i]%h!=h) { c=0; break; } } /*for(int h=0;h<n;h++) { int g=1; for(int k=1;k<n;k++) { g=a[h]*a[k]; int u=(int)(Math.sqrt(g)); if(u*u!=g) { m++; break; } } } int q=(int)(Math.sqrt(c));*/ if(c==0) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
bc422106ca5a89d1013ae135096951ca
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.*; public class Codeforces { public void solve() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = fs.nextInt(); while (t-- > 0 ){ int n = fs.nextInt(); int[]ar = new int[n]; boolean ans = false; int even = 0,odd = 0; ArrayList<Integer> list = new ArrayList<>(); for(int i=0;i<n;i++) { ar[i] = fs.nextInt(); long a = (long)Math.sqrt(ar[i]); if( a*a != ar[i] ){ ans = true; } } if(ans){ out.println("Yes"); }else{ out.println("No"); } } out.flush(); } public static void main(String[]args){ try{ new Codeforces().solve(); }catch (Exception e){ e.printStackTrace(); } } class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f480cb86b87d1bb394006945a3af6338
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.lang.*; import java.io.*; import java.math.*; public class Main{ static int mod=(int)1e9+9; public static void main(String args[]){ InputReader sc = new InputReader(System.in); //write your code int test=sc.nextInt(); while(test-->0){ int n=sc.nextInt(); boolean bool=false; for(int i=0;i<n;i++){ int num=sc.nextInt(); double sqrt=Math.sqrt(num); if(sqrt - Math.floor(sqrt)!= 0) {bool=true;} } if(bool) System.out.println("YES"); else System.out.println("NO"); } } } // for Fast input template class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int snext() { if (snumChars == -1) throw new InputMismatchException(); if (curChar >= snumChars) { curChar = 0; try { snumChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (snumChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public int[] nextIntArray(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } public String readString() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isSpaceChar(c)); return res.toString(); } public String nextLine() { int c = snext(); while (isSpaceChar(c)) c = snext(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isEndOfLine(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
edcb46d04d2fda577fc26d273db040e5
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.StringTokenizer; import java.io.PrintWriter; import java.io.OutputStream; /* * @author : Imtiaz Adar */ public class Perfectly_Imperfect_Array { public static void main(String[] args) { InputReader scan = new InputReader(); OutputStream os = System.out; PrintWriter out = new PrintWriter(os); Driver drive = new Driver(); int n = scan.nextInt(); for(int i = 0; i < n; i++) drive.Raw(scan, out); out.close(); } static class Driver { boolean isPerfectSquare(long num) { long square = 0; if(num > 0){ square = (long)Math.sqrt(num); } return (square*square == num); } void Raw(InputReader scan, PrintWriter out) { StringBuilder sb = new StringBuilder(); long x = scan.nextLong(); boolean stat = false; for(long j = 0; j < x; j++) { long vals = scan.nextLong(); if(!isPerfectSquare(vals)) { stat = true; } } sb.append((stat)? "YES" : "NO"); out.println(sb); } } static class InputReader { BufferedReader readfile = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer token = new StringTokenizer(""); String next() { while (!token.hasMoreTokens()) { try { token = new StringTokenizer(readfile.readLine()); } catch (IOException e) { } } return token.nextToken(); } String nextLine() throws IOException { return readfile.readLine(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } int[] nextIntArray(int size) throws IOException { int[] arr = new int[size]; token = new StringTokenizer(readfile.readLine()); for (int i = 0; i < arr.length; i++) { arr[i] = Integer.parseInt(token.nextToken()); } return arr; } double[] nextDoubleArray(int size) throws IOException { double[] arr = new double[size]; token = new StringTokenizer(readfile.readLine()); for (int i = 0; i < arr.length; i++) { arr[i] = Double.parseDouble(token.nextToken()); } return arr; } long[] nextLongArray(int size) throws IOException { long[] arr = new long[size]; token = new StringTokenizer(readfile.readLine()); for (int i = 0; i < arr.length; i++) { arr[i] = Long.parseLong(token.nextToken()); } return arr; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d7062a28baa5daba18bd09a718a9a8b8
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 HelloWorld{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); long a[] = new long[n]; int l = 7; for(int i=0;i<n;i++) { a[i] = sc.nextLong(); double c1 = (double)Math.pow(a[i],0.5); long test = (long)Math.pow(a[i],0.5); double c2 = (double)test; if(c1!=c2) { l=77; } } if(l==77) { System.out.println("YES"); } else { System.out.println("NO"); } } sc.close(); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d12447283bbded879ba8f867cc5ad992
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 codeforces; import java.util.Scanner; public class PerfectlyImperfectArray { public static void main(String[] args) { // TODO Auto-generated method stub 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(); } int flag=0; for(int i:arr) { if((int)(Math.sqrt(i))*(int)Math.sqrt(i)!=i) { System.out.println("YES"); flag=1; break; } } if(flag==1) { continue; } System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
65f9e9df469e925b0aec0d5e6a5051be
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 Test{ public static void main(String rhf[]){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); } boolean flag=true; for(int i=0;i<n;i++){ if(!issquare(a[i])) {flag=false; break;} } if(flag==false) System.out.println("YES"); else System.out.println("NO"); } sc.close(); } public static boolean issquare(int n){ double num=n; if(num==(int)Math.sqrt(num)*(int)Math.sqrt(num)) return true; else return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
ed5996d2f3389c1f06ade1fa825a32d9
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.Math.*; import static java.util.Arrays.*; public class CF1514A { public static void main(String[] args) throws IOException { int t = ri(); t: while (t-- > 0) { int n = ri(), a[] = ria(n); for (int x : a) { int s = (int) sqrt(x); if (s * s != x) { prY(); continue t; } } prN(); } close(); } static BufferedReader __i = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter __o = new PrintWriter(new OutputStreamWriter(System.out)); static StringTokenizer input; static Random __r = new Random(); // references // IBIG = 1e9 + 7 // IMAX ~= 2e9 // LMAX ~= 9e18 // constants static final int IBIG = 1000000007; static final int IMAX = 2147483647; static final int IMIN = -2147483648; static final long LMAX = 9223372036854775807L; static final long LMIN = -9223372036854775808L; // math util static int minof(int a, int b, int c) {return min(a, min(b, c));} static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;} static long minof(long a, long b, long c) {return min(a, min(b, c));} static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;} static int maxof(int a, int b, int c) {return max(a, max(b, c));} static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;} static long maxof(long a, long b, long c) {return max(a, max(b, c));} static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;} static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;} static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;} static int fli(double d) {return (int) d;} static int cei(double d) {return (int) ceil(d);} static long fll(double d) {return (long) d;} static long cel(double d) {return (long) ceil(d);} static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);} static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);} static int[] exgcd(int a, int b) {if (b == 0) return new int[] {1, 0}; int[] y = exgcd(b, a % b); return new int[] {y[1], y[0] - y[1] * (a / b)};} static long[] exgcd(long a, long b) {if (b == 0) return new long[] {1, 0}; long[] y = exgcd(b, a % b); return new long[] {y[1], y[0] - y[1] * (a / b)};} static int randInt(int min, int max) {return __r.nextInt(max - min + 1) + min;} static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);} // array util static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}} static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}} static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}} static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}} static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}} static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}} static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}} static void rsort(int[] a) {shuffle(a); sort(a);} static void rsort(long[] a) {shuffle(a); sort(a);} static void rsort(double[] a) {shuffle(a); sort(a);} static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;} static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;} static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;} static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;} // input static void r() throws IOException {input = new StringTokenizer(rline());} static int ri() throws IOException {return Integer.parseInt(rline());} static long rl() throws IOException {return Long.parseLong(rline());} static double rd() throws IOException {return Double.parseDouble(rline());} static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;} static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;} static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;} static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;} static char[] rcha() throws IOException {return rline().toCharArray();} static String rline() throws IOException {return __i.readLine();} static String n() {return input.nextToken();} static int rni() throws IOException {r(); return ni();} static int ni() {return Integer.parseInt(n());} static long rnl() throws IOException {r(); return nl();} static long nl() {return Long.parseLong(n());} static double rnd() throws IOException {r(); return nd();} static double nd() {return Double.parseDouble(n());} // output static void pr(int i) {__o.print(i);} static void prln(int i) {__o.println(i);} static void pr(long l) {__o.print(l);} static void prln(long l) {__o.println(l);} static void pr(double d) {__o.print(d);} static void prln(double d) {__o.println(d);} static void pr(char c) {__o.print(c);} static void prln(char c) {__o.println(c);} static void pr(char[] s) {__o.print(new String(s));} static void prln(char[] s) {__o.println(new String(s));} static void pr(String s) {__o.print(s);} static void prln(String s) {__o.println(s);} static void pr(Object o) {__o.print(o);} static void prln(Object o) {__o.println(o);} static void prln() {__o.println();} static void pryes() {prln("yes");} static void pry() {prln("Yes");} static void prY() {prln("YES");} static void prno() {prln("no");} static void prn() {prln("No");} static void prN() {prln("NO");} static boolean pryesno(boolean b) {prln(b ? "yes" : "no"); return b;}; static boolean pryn(boolean b) {prln(b ? "Yes" : "No"); return b;} static boolean prYN(boolean b) {prln(b ? "YES" : "NO"); return b;} static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();} static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();} static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();} static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();} static void h() {prln("hlfd"); flush();} static void flush() {__o.flush();} static void close() {__o.close();}}
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
0bb27006a1117d2971deac2339fdcedc
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 contest04_05; import java.util.*; public class ProblemA { public static void main(String[] args) { Scanner in= new Scanner (System.in); int test= in.nextInt(); for(int t=0;t<test;t++) { int n=in.nextInt(); String ans="NO"; double[] prod= new double[n]; double val=0.0; for(int i=0;i<n;i++) { prod[i]=in.nextDouble(); } for(int i=0;i<n;i++) { //System.out.println(prod[i]+"##"); if(Double.compare((Math.sqrt(prod[i]) % 1) , val)!=0) { //System.out.println(Math.sqrt(prod[i]) ); ans=new String("YES"); break; } } System.out.println(ans); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d726e0a2800174b951b65d789643bf0d
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.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Test{ static FastReader scan; static void solve(){ int n=scan.nextInt(); int []arr=new int[n]; scanInt(arr); for(int i=0;i<n;i++){ if(!perfectSquare(arr[i])){ System.out.println("YES"); return; } } System.out.println("NO"); } static boolean perfectSquare(long n){ long k=(long)Math.sqrt(n); return k*k==n?true:false; } public static void main (String[] args) throws java.lang.Exception{ scan=new FastReader(); int t=scan.nextInt(); while(t-->0){ solve(); } } static void printLong(long []arr){ for(long x:arr)System.out.print(x+" "); } static void printInt(int []arr){ for(int x:arr)System.out.print(x+" "); } static void scanInt(int []arr){ for(int i=0;i<arr.length;i++){ arr[i]=scan.nextInt(); } } static void scanLong(long []arr){ for(int i=0;i<arr.length;i++){ arr[i]=scan.nextLong(); } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } static class Pair implements Comparable<Pair>{ int wt; int idx; Pair(int x,int y){ this.wt=x; this.idx=y; } @Override public int compareTo(Pair x){ return this.wt-x.wt; } public String toString(){ return "("+wt+" "+idx+")"; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
10180ad72109f7c7275860ceca383753
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 test{ static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int t = sc.nextInt(); while(t-- >0){ int n = sc.nextInt(), val =1; int[] arr = new int[n]; boolean v = false; for(int i=0;i<n;i++) { arr[i] = sc.nextInt(); } for(int i=0;i<n;i++) { long y = (long)Math.sqrt(arr[i]); if(y*y!=arr[i]){ v = true; break; } } if(v) System.out.println("yes"); else System.out.println("no"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
74aa39505061bb3e3dcb56038e4a4002
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.StringTokenizer; public class Problem_1 { public static void main(String args[]) { FastScanner sc = new FastScanner(); int testSize = sc.nextInt(); String[] answer = new String[testSize]; outer: for (int t = 0; t < testSize; t++) { int n = sc.nextInt(); answer[t] = "NO"; for (int i = 0; i < n; i++) { int next = sc.nextInt(); if (!isSquare(next)) { answer[t] = "YES"; } } } for (int i = 0; i < testSize; i++) { System.out.println(answer[i]); } } public static boolean isSquare(int x) { for (int i = 1; i <= 100; i++) { int sq = i * i; if (x == sq) { return true; } } return false; } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } long nextLong() { return Long.parseLong(next()); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f2485167f09a60e844f5fb268d6aca89
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 PerfectlyImperfectArray { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for (int i = 0; i < t; i++) { int n=sc.nextInt(); int[] a=new int[n]; for (int j = 0; j < n; j++) { a[j]=sc.nextInt(); } boolean flag=false; for (int j = 0; j< n; j++) { int s=(int) Math.sqrt(a[j]); if(s*s!=a[j]){ flag=true; break; } } if(flag)System.out.println("YES"); else System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
98c532d980922c5e920373e44b74f0f5
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.lang.* ; import java.io.*; public class javaTemplate { static FastReader sc = new FastReader(); // static Scanner sc = new Scanner(System.in) ; public static void main(String[] args) { int t = sc.nextInt() ; while(t -- != 0) { int n = sc.nextInt() ; int arr[] = new int[n] ; boolean val = false ; for(int i = 0 ; i< n ; i++) { arr[i] = sc.nextInt() ; } for(int i = 0 ; i< n ; i++) { int mul = (int)Math.sqrt(arr[i]) ; if((mul*mul) != arr[i]) { val = true ; break ; } } System.out.println(val ? "YES" : "NO"); } } //_________________________//Template//_____________________________________________________________________ // FAST I/O static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } // Modulo static int mod(int a, int m) { return (a%m + m) % m; } // LPS Array static void LPSArray(String pat, int M, int lps[]) { int i = 1 ; int length = 0 ; lps[0] = 0 ; while(i < M) { if(pat.charAt(i) == pat.charAt(length)) { length ++ ; lps[i] = length ; i ++ ; } else if(length != 0) { length = lps[length-1] ; } else { lps[i] = length ; i ++ ; } } } // KMP Search static boolean kmpSearch(String pat, String txt) { boolean val = false ; int M = pat.length() ; int N = txt.length() ; int lps[] = new int[M] ; int j = 0 ; int i = 0 ; LPSArray(pat,M,lps) ; while(i < N) { if(pat.charAt(j) == txt.charAt(i)) { i ++ ; j ++ ; } else if(j != 0) { j = lps[j-1] ; } else { i ++ ; } if(j == M) { val = true ; j = lps[j-1] ; } } return val ; } // Palindrom or Not static boolean isPalindrome(StringBuilder str, int low, int high) { while (low < high) { if (str.charAt(low) != str.charAt(high)) return false; low++; high--; } return true; } // Euler Tortient fx static int Phi(int n) { int count = 0 ; for(int i = 1 ; i< n ; i++) { if(GCD(i,n) == 1) count ++ ; } return count ; } // Integer Sort static void sort(int[] a) { ArrayList<Integer> l=new ArrayList<>(); for (int i:a) l.add(i); Collections.sort(l); for (int i=0; i<a.length; i++) a[i]=l.get(i); } // Long Sort static void sort(long[] a) { ArrayList<Long> l=new ArrayList<>(); for (long i:a) l.add(i); Collections.sort(l); for (int i=0; i<a.length; i++) a[i]=l.get(i); } // boolean Value static void val(boolean val) { System.out.println(val ? "YES" : "NO"); System.out.flush(); } // GCD public static int GCD(int a , int b) { if(b == 0) return a ; return GCD(b, a%b) ; } // sieve public static boolean [] sieveofEratosthenes(int n) { boolean isPrime[] = new boolean[n+1] ; Arrays.fill(isPrime, true); isPrime[0] = false ; isPrime[1] = false ; for(int i = 2 ; i * i <= n ; i++) { for(int j = 2 * i ; j<= n ; j+= i) { isPrime[j] = false ; } } return isPrime ; } // fastPower public static long fastPowerModulo(long a, long b, long n) { long res = 1 ; while(b > 0) { if((b&1) != 0) { res = (res * a % n) % n ; } a = (a % n * a % n) % n ; b = b >> 1 ; } return res ; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
e1dd04c271dc5d76fa63819026444366
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 random{ static boolean check(int n){ for(int i=0;i<=Math.sqrt(n);i++) { if(n==i*i) return true; } return false; } public static void main(String args[]){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) a[i]=sc.nextInt(); boolean flag=true; for(int i=0;i<n;i++){ if(!check(a[i])){ flag=false; break; } } if(flag) System.out.println("NO") ; else System.out.println("YES") ; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
388440aeeb2697d2c9ed14d0fb76bf64
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.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while(n-- >0){ boolean imp = false; int count = 0; int j = sc.nextInt(); for(int i=0; i<j; i++){ int sum = sc.nextInt(); double sq = Math.sqrt(sum); //System.out.println(sq); //System.out.println(Math.floor(sq)); //System.out.println(Math.ceil(sq)); imp = ((sq - Math.ceil(sq)) != 0); if(imp){ count++; } } System.out.println(count>0?"YES":"NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
26d4422e37454ef0883954fb31f57fd3
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 MyClass { public static void main(String args[]) { HashSet<Integer> hs = new HashSet<>(); for(int i=1;i<10001;i++) { hs.add(i*i); } Scanner sc = new Scanner(System.in); int test = sc.nextInt(); while(test-- != 0) { int n = sc.nextInt(); int a = 0; boolean check = false; for(int i=0;i<n;i++) { a = sc.nextInt(); if(hs.contains(a) == false) check = true; } if(check == true) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
43e558ca89e7b91c610551e259b5dafe
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 MyClass { public static void main(String args[]) { HashSet<Integer> hs = new HashSet<>(); for(int i=1;i<10001;i++) { hs.add(i*i); } Scanner sc = new Scanner(System.in); int test = sc.nextInt(); while(test-- != 0) { int n = sc.nextInt(); int a = 0; int[] f = new int[10001]; boolean check = false; for(int i=0;i<n;i++) { a = sc.nextInt(); if(hs.contains(a) == false) f[a]++; } for(int i=1;i<10001;i++) { if(f[i] >= 1 && i!=1) { check = true; break; } } if(check == true) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
c5b8a75b2840853da4e2b13c7daeda4c
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(); boolean f=false; int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); int p=(int)Math.sqrt(a[i]); if(p*p!=a[i]) f=true; } if(f) System.out.println("YES"); else System.out.println("NO"); t--; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
4e318ad6a329d655153999e2113eadd6
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.Scanner; import java.util.StringTokenizer; import java.io.*; import java.util.*; import java.text.DecimalFormat; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } // function to find // the rightmost set bit static int PositionRightmostSetbit(int n) { // Position variable initialize // with 1 m variable is used to // check the set bit int position = 1; int m = 1; while ((n & m) == 0) { // left shift m = m << 1; position++; } return position; } // used for swapping ith and jth elements of array public static void swap(int[] arr, int i, int j) { System.out.println("Swapping " + arr[i] + " and " + arr[j]); int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } static boolean palindrome(String s) { return new StringBuilder(s).reverse().toString().equals(s); } static int countDigit(long n) { return (int)Math.floor(Math.log10(n) + 1); } static boolean isPerfectSquare(double x) { double sq = Math.sqrt(x); /* Math.floor() returns closest integer value, for * example Math.floor of 984.1 is 984, so if the value * of sq is non integer than the below expression would * be non-zero. */ return ((sq - Math.floor(sq)) == 0); } public static void main(String[] args) { try { System.setIn(new FileInputStream("input.txt")); System.setOut(new PrintStream(new FileOutputStream("output.txt"))); } catch (Exception e) { System.err.println("Error"); } FastReader sc = new FastReader(); int t = Integer.parseInt(sc.next()); // int t = 1; while(t-->0){ int n = sc.nextInt(); int a[] = new int[n]; for (int i = 0; i<n; i++) { a[i] = sc.nextInt(); } boolean f = false; for (int i = 0; i<n; i++) { if(isPerfectSquare(a[i])){ continue; }else{ f = true; break; } } if(f){ System.out.println("YES"); } else{ System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
c3c1a308235cc4accf2312b1a69eaf44
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; public class Main { public static void main(String[] args) { BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); try { int n = Integer.valueOf(read.readLine()); for (int tests = 0; tests < n; tests++) { int len = Integer.valueOf(read.readLine()); String[] input = read.readLine().split(" "); boolean returned = false; for (int i = 0; i < len; i++) { if (!isSquare(Integer.valueOf(input[i]))) { System.out.println("YES"); returned = true; break; } } if (returned) continue; System.out.println("NO"); } } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } static boolean isSquare(int n) { int sqrt = (int) Math.sqrt(n); if (sqrt * sqrt == n) return true; return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
6f3602b2b2b9ae94b77372008999680c
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) { // TODO Auto-generated method stub Scanner scn = new Scanner(System.in); int X = scn.nextInt(); for(int i=1;i<=X;i++) { int Y = scn.nextInt(); int [] arr = new int[Y]; for(int j =0;j<Y;j++) { arr[j] = scn.nextInt(); } boolean flag = true; for(int j =0;j<Y;j++) { if(isPerfectSquare(arr[j])==false) { System.out.println("YES"); flag=false; break; } } if(flag==true) { System.out.println("NO"); } } } public static boolean isPerfectSquare(double x) { if (x >= 0) { // Find floating point value of // square root of x. int sr = (int)Math.sqrt(x); // if product of square root // is equal, then // return T/F return ((sr * sr) == x); } return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
2cbf5e0c46049cfd3a36d3202815ca9e
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 Prob1{ public static void main(String args[]){ Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-- > 0){ int n = s.nextInt(); int arr[] = new int[n]; for(int i=0;i<n;i++) arr[i] = s.nextInt(); long prod = 1; int flag = 0; for(int i=0;i<n;i++){ double sqrt = Math.sqrt(arr[i]); if(Math.floor(sqrt) != Math.ceil(sqrt)){ flag = 1; break; } // prod *= (long)arr[i]; // sqrt = Math.sqrt(prod); // if(Math.floor(sqrt) != Math.ceil(sqrt)){ // flag = 1; // break; // } } if(flag == 1){ System.out.println("YES"); } else{ System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
54349201d205a8c028c1f64c36dc0ea8
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.Scanner; import java.util.StringTokenizer; import java.util.*; public class CodeForces { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public static void main(String[] args) { FastReader in = new FastReader(); int t = in.nextInt(); while(t-->0) { int n = in.nextInt(); int a[] = new int[n]; int i; for(i=0;i<n;i++) { a[i] = in.nextInt(); } int j; double s = 0.0; int p = 1; String ans = "NO"; for(i=0;i<n;i++) { s = Math.sqrt(a[i]); if(s - (int)Math.floor(s) != 0) { ans = "YES"; break; } } System.out.println(ans); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f0c93cfc829d43bf168a557fa20f26ae
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.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); StringTokenizer st; while(t-->0){ int n = Integer.parseInt(br.readLine()); st = new StringTokenizer(br.readLine(), " "); int i = 0; for (; i <n; i++) { int p = Integer.parseInt(st.nextToken()); if(p!=(int)(Math.pow((int)Math.sqrt(p), 2))){ System.out.println("YES"); break; } } if(i==n) System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
1ece47bec4847865c43b95f2c139f226
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.lang.*; import java.math.*; import java.io.*; import java.util.*; public class Practice{ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } static int gcd(int a, int b) { if (b == 0) { return a;} else { return gcd(b, a % b);}} //for prime no static boolean isPrime(int n) { return BigInteger.valueOf(n).isProbablePrime(1); } static boolean isPrime(long n) { return BigInteger.valueOf(n).isProbablePrime(1); } static boolean[] seiveOfEratoSthenes(int n) { boolean isPrime[]=new boolean[n+1]; Arrays.fill(isPrime, true); isPrime[0]=false; isPrime[1]=false; for(int i=2;i<=Math.sqrt(n);i++) { for(int j=2*i;j<=n;j+=i) { isPrime[j]=false; } } return isPrime; } static long modulo(long a,long b,int n) { long res=1; while(b>0) { if((b&1)==1) { res=(res*(a%n))%n; } a=((a%n)*(a%n))%n; b=b>>1; } return res; } static class Pair implements Comparable<Pair>{ double a; int b; Pair(double tim,int index){ this.b=index; this.a=tim; } public int compareTo(Pair st){ if(a==st.a) return b-st.b; else if(a>st.a) return 1; else return -1; } } static boolean isPalindrome(String s) { int length = s.length(); for (int i = 0; i < length / 2; i++) { if (s.charAt(i) != s.charAt(length - 1 - i)) { return false; } } return true; } static void reverseArray(int[] arr) { for (int i = 0; i < arr.length / 2; i++) { int temp = arr[i]; arr[i] = arr[arr.length - 1 - i]; arr[arr.length - 1 - i] = temp; } } static void reverseArray(String[] arr) { for (int i = 0; i < arr.length / 2; i++) { String temp = arr[i]; arr[i] = arr[arr.length - 1 - i]; arr[arr.length - 1 - i] = temp; } } static void reverseArray(char[] arr) { for (int i = 0; i < arr.length / 2; i++) { char temp = arr[i]; arr[i] = arr[arr.length - 1 - i]; arr[arr.length - 1 - i] = temp; } } public static void main(String[] args) { FastReader sc = new FastReader(); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int arr[]=new int[n]; long sum=1; boolean right=false; for(int i=0;i<n;i++) { arr[i]=sc.nextInt(); if(perfect(arr[i])) { continue; } sum*=arr[i]; right=true; } if(right) {System.out.println("YES");} else {System.out.println("NO");} } } static boolean perfect(long a) { double sqrt=Math.sqrt(a); if(sqrt==(long)sqrt) { return true; } return false; } static int binary(int start,int end,int arr[],int v ) { int Q=0; if (end <= start) { Q=(v >= arr[start])? start : (start-1); } else{ int mid = (start + end)/2; if(v == arr[mid]) return mid; if(v >arr[mid]) { Q= binary( mid+1, end,arr, v); } else if(v <arr[mid]){ Q= binary( start, mid-1,arr, v); }} return Q; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
e22b6195b54f8b97464f4b40f89f0069
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.HashMap; import java.util.StringTokenizer; public class Qus1 { static HashMap<Integer, Integer> hashMap; public static void main(String[] args) { handmadeInput.FastReader in = new handmadeInput.FastReader(); int t = in.nextInt(); while (t-- > 0) { int n = in.nextInt(); int[] qus = new int[n]; hashMap = new HashMap<>(n); for (int i = 0; i < n; i++) { qus[i] = in.nextInt(); if (!isPerfectSquare(qus[i])) { if (!hashMap.containsKey(qus[i])) { hashMap.put(qus[i], 1); } else { hashMap.replace(qus[i], hashMap.get(qus[i])); } } } boolean b=false; for(int i:hashMap.keySet()){ if(hashMap.get(i)%2!=0){ b=true; } break; } if(b){ System.out.println("YES"); } else{ System.out.println("NO"); } } } private static boolean isPerfectSquare(int x) { int y = (int) Math.sqrt(x); return y * y == x; } } class handmadeInput { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d3685fd29607e0d10243ca2b2b5e8fd0
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.*; public class CodeF1 { // .....................................input stuff started.................................... private static StringTokenizer st; public static void nextLine(BufferedReader br) throws IOException { st = new StringTokenizer(br.readLine()); } public static int nextInt() { return Integer.parseInt(st.nextToken()); } public static String next() { return st.nextToken(); } public static long nextLong() { return Long.parseLong(st.nextToken()); } public static double nextDouble() { return Double.parseDouble(st.nextToken()); } // .....................................input stuff ends.................................... static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); static boolean prime[]; public static void genSeive(){ prime=new boolean[1000001]; Arrays.fill(prime,true); prime[0]=false; prime[1]=false; for(int i=2;i*i<=1000000;i++) if(prime[i]) for(int j=2*i;j<=1000000;j+=i) prime[j]=false; } public static void solve() throws IOException{ nextLine(br); int n=nextInt(); nextLine(br); int[] arr=new int[n]; // HashSet<Integer> set=new HashSet<>(); for(int i=0;i<n;i++){ arr[i]=nextInt(); // set.add(arr[i]); } // if(set.size()!=n){ // out.append("NO\n"); // return ; // } for(int i=0;i<n;i++){ if((int)Math.pow(arr[i],0.5)!=Math.pow(arr[i],0.5)){ out.append("YES\n"); return; } } out.append("NO\n"); } public static void main(String[] args) throws IOException { genSeive(); nextLine(br); int t=nextInt(); while(t-- >0) solve(); out.flush(); out.close(); } static int gcd(int a, int b) { // if b=0, a is the GCD if (b == 0) return a; // call the gcd() method recursively by // replacing a with b and b with // modulus(a,b) as long as b != 0 else return gcd(b, a % b); } // lcm() method returns the LCM of a and b static int lcm(int a, int b, int gcdValue) { return Math.abs(a * b) / gcdValue; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f532b0b787684c6c2662fa873d229585
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.math.*; //import java.io.*; public class Experiment { static Scanner in=new Scanner(System.in); // static BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); public static void sort(int ar[],int l,int r) { if(l<r) { int m=l+(r-l)/2; sort(ar,l,m); sort(ar,m+1,r); merge(ar,l,m,r); } } public static void merge(int ar[],int l,int m,int r) { int n1=m-l+1;int n2=r-m; int L[]=new int[n1]; int R[]=new int[n2]; for(int i=0;i<n1;i++) L[i]=ar[l+i]; for(int i=0;i<n2;i++) R[i]=ar[m+i+1]; int i=0;int j=0;int k=l; while(i<n1 && j<n2) { if(L[i]<=R[j]) { ar[k++]=L[i++]; }else { ar[k++]=R[j++]; } } while(i<n1) ar[k++]=L[i++]; while(j<n2) ar[k++]=R[j++]; } public static int[] sort(int ar[]) { sort(ar,0,ar.length-1); //Array.sort uses O(n^2) in its worst case ,so better use merge sort return ar; } public static void func(int ar[]) { int k=0; for(int ele:ar) { if((double)(int)Math.sqrt(ele)==Math.sqrt(ele)) { k++; }} if(k==ar.length) System.out.println("NO"); else System.out.println("YES"); } public static void main(String[] args) { int t=in.nextInt(); while(t!=0) { int n=in.nextInt(); int ar[]=new int[n]; int p=1; for(int i=0;i<n;i++) { ar[i]=in.nextInt(); // p=p*ar[i]; } func(ar); t--; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
1a55c0b496b72a66280e74263f8e9dbe
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.lang.*; import java.io.*; public class CP { static boolean isSqr(int n){ double sqrt=Math.sqrt(n); //finds the floor value of the square root and comparing it with zero return ((sqrt - Math.floor(sqrt)) == 0); } public static void main (String[] args) throws java.lang.Exception { FastReader src =new FastReader(); int t=src.nextInt(); while(t-->0) { int n = src.nextInt(); int[] array = src.readArray(n); int flag =0; for(int i=0;i<n;i++){ if(!isSqr(array[i])){ flag=1; break; } } if(flag==1){ System.out.println("YES"); } else{ System.out.println("NO"); } } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } float nextFloat() { return Float.parseFloat(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } int[] readArray(int n) { int[] a=new int[n]; for (int i=0; i<n; i++) a[i]=nextInt(); return a; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
8d00a5601cb5d90590e3a654de788b8e
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.*; public class Codeforces1 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(st == null || !st.hasMoreElements()){ try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt(){return Integer.parseInt(next());} long nextLong(){return Long.parseLong(next());} double nextDouble(){return Double.parseDouble(next());} String nextLine(){ String str = ""; try { str=br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public static void main(String[] args)throws IOException { FastReader sc = new FastReader(); BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out)); //t -> test cases; long t = sc.nextLong(); while(t-->0){ int n = sc.nextInt(); boolean flag = false; for(int i=0; i<n; i++){ int a = sc.nextInt(); double sq = Math.sqrt(a); if(sq*10%10 != 0){ flag=true; } } if(flag) output.write("YES"+"\n"); else output.write("NO"+"\n"); } output.flush(); } //Number of bits static int numberOfBits(int n){ return (int)(Math.log(n)/Math.log(2)+1); } //GCD of a Two number static long GCD(long a, long b){ if(b==0) return a; return GCD(b, a%b); } //No of factors in factorial n i.e. (n!) static long factors(long n, long b){ long count =0; int power = 1; while(n>=b){ count+=n/b; b=(long)Math.pow(b, ++power); } return count; } //prime numbers in a range from 2 to n static boolean[] primeUptoN(int n){ boolean arr[]= new boolean[n]; return arr; } //Round off static double roundOff(double value, int digit){ double mul = Math.pow(10.0, digit); value=Math.round((value*mul)/mul); return value; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
3d228f58b1ecfce912a04240a6cf3928
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.* ; public class App { public static void main (String[] args) throws java.lang.Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); //reader = new BufferedReader(new FileReader(new File("C:\\Users\\Anjali\\Desktop\\projects\\HelloWorld\\src\\input.txt"))); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out)); //writer = new BufferedWriter(new FileWriter(new File("C:\\Users\\Anjali\\Desktop\\projects\\HelloWorld\\src\\output.txt"))); //int tests = Integer.parseInt(reader.readLine()); int tests = 1; //StringBuilder sb = new StringBuilder(tests); while (tests-- > 0){ solve(reader, writer); writer.write("\n"); } reader.close(); writer.flush(); writer.close(); } static void solve(BufferedReader reader, BufferedWriter writer) throws IOException { int tests = Integer.parseInt(reader.readLine()); for (int j = 0; j < tests; j++) { int n = Integer.parseInt(reader.readLine()); int[] a = new int[n]; String[] input = reader.readLine().split(" "); for(int i = 0; i < n; i++) { a[i] = Integer.parseInt(input[i]); } int found = 0; for(int k = 0; k < n; k++) { found = 0; for (int i = 1; (i * i) <= a[k]; i++) { if ((a[k] % i == 0) && (a[k] / i == i)) { found = 1; break; } } if (found == 0) { break; } } if (found == 1) { writer.write("NO\n"); } else { writer.write("YES\n"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
e6ddc02b5768cf061dfbe781dbc521bc
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.lang.*; 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 a = 0; for(int i =0;i<n;++i) { int y = sc.nextInt(); if((int)Math.sqrt(y) != Math.sqrt(y)) { a++; } } if(a>0) System.out.println("YES"); else System.out.println("NO"); t--; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
c0362ecf80011abeeb31c7c77a24d50d
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.lang.Math; import java.util.*; public class A { public static void main(String[] args){ Scanner s = new Scanner(System.in); int a = s.nextInt(); for(int i = 0;i < a; i++){ int b = s.nextInt(); boolean check = false; for(int j = 0; j < b; j++){ int c = s.nextInt(); if(!isPerfectSquare(c)){ if(!check) { System.out.println("YES"); } check = true; } } if(check == false){ System.out.println("NO"); } } } public static boolean isPerfectSquare(int n){ double sqrtWithDecimals = Math.sqrt(n); int sqrtWithoutDecimals = (int)Math.sqrt(n); if(sqrtWithDecimals == (double)sqrtWithoutDecimals){ return true; } return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
0bd23edc44ba3b6028aeb77e767ce78e
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.lang.*; import java.io.*; public class Main { public static String check(int a[],int n) { for(int i=0;i<n;i++) { long k=(int)Math.sqrt(a[i]); if(k*k!=a[i]) return "YES"; } return "NO"; } public static void main (String[] args) throws java.lang.Exception { Scanner s = new Scanner(System.in); int t=s.nextInt(); while(t-->0) { int n=s.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) a[i]=s.nextInt(); System.out.println(check(a,n)); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
adb03afc22607fe77dced82cc3c77a4f
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 PerfectlyImperfectArray { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while (t-- > 0) { int n = s.nextInt(); int[] a = new int [n]; for (int i = 0; i < n; i++) { a[i] = s.nextInt(); } boolean check=false; for (int i = 0; i < n; i++) { double ans= (double) a[i]; double x=Math.ceil(Math.sqrt(ans)); double y=Math.floor(Math.sqrt(ans)); if (x-y !=0) { check=true; break; } } if (check) { System.out.println("Yes"); } else { System.out.println("No"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f7b650d194e1030335d351303698ef90
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; /** * * @author Acer */ public class PerfectlyImperfectArray { 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(); } boolean flag = false; for (int i = 0; i < n; i++) { double x = (double)arr[i]; double y = Math.ceil(Math.sqrt(x)); double z = Math.floor(Math.sqrt(x)); if(y-z != 0){ flag = true; break; } } if(flag){ System.out.println("YES"); } else{ System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f47414f366f3293fc136b5896e5b8e3f
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 n=sc.nextInt(); for(int i=0;i<n;i++){ int size= sc.nextInt(); int[] arr = new int[size]; for(int j=0;j<arr.length;j++){ arr[j] = sc.nextInt(); } if(perfect(arr)){ System.out.println("Yes"); } else{ System.out.println("No"); } } } public static boolean perfect(int[] arr){ for(int i:arr){ int temp = (int)Math.sqrt(i); if(temp*temp == i){ continue; } else{ return true; } } return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
7fbf8f5b05ba27a075bf2ed860716f6a
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 Codeforces { final static long mod = 1000000007; public static void main(String[] args) { FastReader sc = new FastReader(); int t = sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int a[]= new int[n]; int c=0; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); if(!checkPerfectSquare(a[i])) c++; } System.out.println(c>0?"YES":"NO"); } } static boolean checkPerfectSquare(double number) { //calculating the square root of the given number double sqrt=Math.sqrt(number); //finds the floor value of the square root and comparing it with zero return ((sqrt - Math.floor(sqrt)) == 0); } static class FastReader { BufferedReader br; StringTokenizer st; // StringTokenizer() is used to read long strings public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public class Pair implements Comparable<Pair> { public final int index; public final int value; public Pair(int index, int value) { this.index = index; this.value = value; } @Override public int compareTo(Pair other) { // multiplied to -1 as the author need descending sort order return -1 * Integer.valueOf(this.value).compareTo(other.value); } } static String reverseString(String str) { StringBuilder input = new StringBuilder(); return input.append(str).reverse().toString(); } static long factorial(int n, int b) { if (n == b) return 1; return n * factorial(n - 1, b); } static int lcm(int ch, int b) { return ch * b / gcd(ch, b); } static int gcd(int ch, int b) { return b == 0 ? ch : gcd(b, ch % b); } static double ceil(double n, double k) { return Math.ceil(n / k); } static int sqrt(double n) { return (int) Math.sqrt(n); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
2fd891f7494d1a485111e235d11cdf50
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 CF_1517A { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int testCase = scan.nextInt(); while (testCase != 0) { int arrayLimit = scan.nextInt(); boolean result = false; int[] arrayNumbers = new int[arrayLimit]; for (int i = 0; i < arrayLimit; i++) { arrayNumbers[i] = scan.nextInt(); int value = (int) Math.sqrt(arrayNumbers[i]); if(value*value != arrayNumbers[i]) { result = true; } } System.out.println((result) ? "Yes" : "No"); testCase--; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
48c7992dcca18fc3712af84fb95f5401
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
/*Author Adityaraj*/ import java.awt.Color; import java.io.*; import java.math.BigInteger; import java.security.spec.ECPublicKeySpec; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { // Initialize the reader FastScanner scan = new FastScanner(); // Initialize the writer FastOutput out = new FastOutput(); /************************************************************************************************************************************/ // writer your code here int t = scan.readInt(); while (t-->0) { int n = scan.readInt(); int[] arr = scan.readIntArray(n); boolean flag = true; for (int i = 0; i < arr.length; i++) { flag = perfect_square(Long.valueOf(arr[i])); if(flag == false){ out.writeString("YES"); flag = false; break; } } if(flag){ out.writeString("NO"); } } /*************************************************************************************************************************************/ } /**************************************************************************************************************************************/ // do not touch it /**************************************************************************************************************************************/ //Write here the function which do you want to insert into the code during the sumbition // this function will the gcd of two numbers public static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } // this will return the pow of a^b public static long bin_exp(long a, long b) { long res = 1; while (b != 0) { if (b % 2 != 0) res *= a; a *= a; b /= 2; } return res; } // this will return true if a is prime and false if not public static boolean primeornot(long a) { for (int i = 2; i * i <= a; i++) { if (a % i == 0) { // System.out.println(i); return false; } } return true; } // this function will check that a given string is palindrome or not public static boolean palindrome(String string) { StringBuffer buffer = new StringBuffer(string); buffer = buffer.reverse(); if (string.equals(buffer.toString())) { return true; } return false; } // this function count the number of digit in a number public static int count_Digit(long a ) { int count = 0 ; while(a!=0){ a = a/10; count++; } return count; } // this function will check weather a number is a perfect_square or not public static boolean perfect_square(Long n) { if (n>=0){ if (Math.ceil((double)Math.sqrt(n)) == Math.floor((double)Math.sqrt(n))){ return true; } } return false; } /*************************************************************************************************************************/ /****************************************************************************************************************************************/ // Fast Reader Class public static class FastScanner { // Reader object BufferedReader reader; // Constructor public FastScanner() { // Initialize the reader reader = new BufferedReader(new InputStreamReader(System.in)); if (System.getProperty("ONLINE_JUDGE") == null) { try { reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"))); } catch (Exception e) { } } } // String tokenizer StringTokenizer tokenizer; // Function to read a // single integer // to extend the fast reader class writer your function here public int readInt() throws IOException { return Integer.parseInt(reader.readLine()); } // Function to read a // single long public long readLong() throws IOException { return Long.parseLong(reader.readLine()); } // Function to read string public String readString() throws IOException { return reader.readLine(); } // Function to read a array // of numsInts integers // in one line public int[] readIntArray(int numInts) throws IOException { int[] nums = new int[numInts]; tokenizer = new StringTokenizer(reader.readLine()); for (int i = 0; i < numInts; i++) { nums[i] = Integer.parseInt(tokenizer.nextToken()); } return nums; } public Long[] readLongArray(int n) throws IOException { tokenizer = new StringTokenizer(reader.readLine()); Long[] arr = new Long[n]; int i = 0; while (tokenizer.hasMoreTokens()) { arr[i] = Long.parseLong(tokenizer.nextToken()); i++; } return arr; } public List<Integer> readIntAsList() throws IOException { List<Integer> list = new ArrayList<Integer>(); tokenizer = new StringTokenizer(reader.readLine()); while (tokenizer.hasMoreTokens()) { list.add(Integer.parseInt(tokenizer.nextToken())); } return list; } } // Fast Writer Class public static class FastOutput { // Writer object BufferedWriter writer; // Constructor public FastOutput() { // Initialize the writer writer = new BufferedWriter(new OutputStreamWriter(System.out)); if (System.getProperty("ONLINE_JUDGE") == null) { try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("output.txt"))); } catch (Exception e) { } } } // Function to write the // single integer public void writeInt(int i) throws IOException { writer.write(Integer.toString(i)); writer.newLine(); writer.flush(); } // Function to write single long public void writeLong(long i) throws IOException { writer.write(Long.toString(i)); writer.newLine(); writer.flush(); } // Function to write String public void writeString(String s) throws IOException { writer.write(s); writer.newLine(); writer.flush(); } public void writeStringWithSpace(String s) throws IOException { writer.write(s); writer.write(" "); writer.flush(); } // Function to write a Integer of // array with spaces in one line public void writeIntArray(int[] nums) throws IOException { for (int i = 0; i < nums.length; i++) { writer.write(nums[i] + " "); } writer.newLine(); writer.flush(); } // Function to write Integer of // array without spaces in 1 line public void writeIntArrayWithoutSpaces(int[] nums) throws IOException { for (int i = 0; i < nums.length; i++) { writer.write(Integer.toString(nums[i])); } writer.newLine(); writer.flush(); } public void writelist(List<Integer> num) throws IOException { if (num != null) { for (Integer integer : num) { writer.write(integer + " "); } } writer.newLine(); writer.flush(); } public void write_matrix(int[][] matrix) throws IOException { for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[0].length; j++) { writer.write(matrix[i][j] + " "); } writer.newLine(); } writer.newLine(); writer.flush(); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
b81793d7f9f826fcacdb7d059ec6bdf3
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 kickStart { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ void printArray(int[] arr) { System.out.println(Arrays.toString(arr)); } void printArray(String[] arr) { System.out.println(Arrays.toString(arr)); } void printArray(long[] arr) { System.out.println(Arrays.toString(arr)); } void print(int data) { System.out.println(data); } void print(String data) { System.out.println(data); } void print(long data) { System.out.println(data); } int[] II(int n) { int[] d = new int[n]; String[] arr = nextLine().split(" "); for (int i = 0; i < n; i++) { d[i] = Integer.parseInt(arr[i]); } return d; } String[] IS(int n) { return nextLine().split(" "); } long[] IL(int n) { long[] d = new long[n]; String[] arr = nextLine().split(" "); for (int i = 0; i < n; i++) { d[i] = Long.parseLong(arr[i]); } return d; } } public static void main(String[] args) { FastReader fs = new FastReader(); int t = fs.nextInt(); for (int idx = 1; idx <= t; ++idx) { int n = fs.nextInt(); int[] arr = fs.II(n); operation(arr, n); } } private static void operation(int[] arr, int n){ for(int i = 0; i < n; i++){ int root = (int)Math.floor(Math.sqrt(arr[i])); // System.out.println(root); if(root*root != arr[i]) { System.out.println("YES"); return; } } System.out.println("NO"); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
7714374abf111f054b8ac2b5a029affe
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.math.*; import java.lang.*; public class blipblop { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); long a[] = new long[n]; for(int i=0 ; i<n ; i++) { a[i]=sc.nextLong(); } boolean flag=true; for(int i=0 ; i<n ; i++) { double x=Math.sqrt(a[i]); if(Math.floor(x)!=x) { flag=false; System.out.println("YES"); break; } } if(flag) { System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
7252a766a2978ddda29df9660c69e137
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.util.Scanner; import java.lang.*; import java.lang.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner Sc=new Scanner(System.in); int t=Sc.nextInt(); while((t--)>0){ int n=Sc.nextInt(); boolean f=false; for(int i=0;i<n;i++) { int val=Sc.nextInt(); int x=(int)Math.sqrt(val); if(val!=x*x) { f=true; } } if(f) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
c52afa52561c96a186fc9cd2a92a6178
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 scn=new Scanner(System.in); int t=scn.nextInt(); while(t-->0){ int n=scn.nextInt(); int []arr=new int[n]; for(int i=0;i<n;i++){ arr[i]=scn.nextInt(); } boolean flag=false; for(int i=0;i<n;i++){ double d=Math.pow(arr[i], 0.5); int doub=(int)d; if((d-(double)doub)>0.00){ flag=true; break; } } if(flag){ System.out.println("YES"); }else{ System.out.println("NO"); } } scn.close(); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
b022a8cd8ea570430d2e75e1adb40b79
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.*; public class fact { public static boolean checkPerfectSquare(double number) { double sqrt=Math.sqrt(number); return ((sqrt - Math.floor(sqrt)) == 0); } 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]; int count =0; for (int i = 0; i < arr.length; i++) { arr[i] = sc.nextInt(); if(!checkPerfectSquare(arr[i])){ count++; } } if(count>0){ System.out.println("YES"); } else{ System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
3f166abc9acfad4959dcf14ad77a8903
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Scanner; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author valeesi */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); APerfectlyImperfectArray solver = new APerfectlyImperfectArray(); int testCount = Integer.parseInt(in.next()); for (int i = 1; i <= testCount; i++) solver.solve(i, in, out); out.close(); } static class APerfectlyImperfectArray { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); int[] arr = in.nextIntArray(n); for (int i = 0; i < arr.length; i++) { int sq = (int) Math.sqrt(arr[i]); if (sq * sq != arr[i]) { out.println("YES"); return; } } out.println("NO"); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public Scanner scanner; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); scanner = new Scanner(reader); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
26d43899ca5fdc1f2d04775114875558
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.InputStream; import java.io.InputStreamReader; import java.util.InputMismatchException; import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; private BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars==-1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if(numChars <= 0) return -1; } return buf[curChar++]; } public String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } public int nextInt() { int c = read(); while(isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if(c<'0'||c>'9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public double nextDouble() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } double res = 0; while (!isSpaceChar(c) && c != '.') { if (c == 'e' || c == 'E') return res * Math.pow(10, nextInt()); if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } if (c == '.') { c = read(); double m = 1; while (!isSpaceChar(c)) { if (c == 'e' || c == 'E') return res * Math.pow(10, nextInt()); if (c < '0' || c > '9') throw new InputMismatchException(); m /= 10; res += (c - '0') * m; c = read(); } } return res * sgn; } public String readString() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public String next() { return readString(); } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } static long gcd(long a, long b){ if (a == 0) return b; return gcd(b % a, a); } static long lcm(long a, long b) { return (a*b)/gcd(a, b); } public static void sortbyColumn(int arr[][], int col) { Arrays.sort(arr, new Comparator<int[]>() { @Override public int compare(final int[] entry1, final int[] entry2) { if (entry1[col] > entry2[col]) return 1; else return -1; } }); } static long func(long a[],int size,int s){ long max1=a[s]; long maxc=a[s]; for(int i=s+1;i<size;i++){ maxc=Math.max(a[i],maxc+a[i]); max1=Math.max(maxc,max1); } return max1; } public static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> { public U x; public V y; public Pair(U x, V y) { this.x = x; this.y = y; } public int hashCode() { return (x == null ? 0 : x.hashCode() * 31) + (y == null ? 0 : y.hashCode()); } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<U, V> p = (Pair<U, V>) o; return (x == null ? p.x == null : x.equals(p.x)) && (y == null ? p.y == null : y.equals(p.y)); } public int compareTo(Pair<U, V> b) { int cmpU = x.compareTo(b.x); return cmpU != 0 ? cmpU : y.compareTo(b.y); } public String toString() { return String.format("(%s, %s)", x.toString(), y.toString()); } } static class MultiSet<U extends Comparable<U>> { public int sz = 0; public TreeMap<U, Integer> t; public MultiSet() { t = new TreeMap<>(); } public void add(U x) { t.put(x, t.getOrDefault(x, 0) + 1); sz++; } public void remove(U x) { if (t.get(x) == 1) t.remove(x); else t.put(x, t.get(x) - 1); sz--; } } static void shuffle(long[] a) { Random get = new Random(); for (int i = 0; i < a.length; i++) { int r = get.nextInt(a.length); long temp = a[i]; a[i] = a[r]; a[r] = temp; } } static long myceil(long a, long b){ return (a+b-1)/b; } static long C(long n,long r){ long count=0,temp=n; long ans=1; long num=n-r+1,div=1; while(num<=n){ ans*=num; //ans+=MOD; ans%=MOD; ans*=mypow(div,MOD-2); //ans+=MOD; ans%=MOD; num++; div++; } ans+=MOD; return ans%MOD; } static long fact(long a){ long i,ans=1; for(i=1;i<=a;i++){ ans*=i; ans%=MOD; } return ans%=MOD; } static void sieve(int n){ is_sieve[0]=1; is_sieve[1]=1; int i,j,k; for(i=2;i<n;i++){ if(is_sieve[i]==0){ sieve[i]=i; tr.add(i); for(j=i*i;j<n;j+=i){ if(j>n||j<0){ break; } is_sieve[j]=1; sieve[j]=i; } } } } // static void calc(int n){ // int i,j; // dp[n-1]=0; // if(n>1) // dp[n-2]=1; // for(i=n-3;i>=0;i--){ // long ind=n-i-1; // dp[i]=((ind*(long)mypow(10,ind-1))%MOD+dp[i+1])%MOD; // } // } static long mypow(long x,long y){ long temp; if( y == 0) return 1; temp = mypow(x, y/2); if (y%2 == 0) return (temp*temp)%MOD; else return ((x*temp)%MOD*(temp)%MOD)%MOD; } static long dist[],dp[][]; static int visited[],isit[]; static ArrayList<Integer> adj[],li; //static int dp[][][]; static int MOD=1000000007,max=0; static char ch[]; static int[] sieve,is_sieve; static TreeSet<Integer> tr; static long mat[][]; public static void main(String args[]){ InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter w = new PrintWriter(outputStream); int t,i,j,tno=0,tte; t=in.nextInt(); //t=1; //tte=t; while(t-->0){ int n=in.nextInt(); int arr[]=new int[n]; int flag=0;for(i=0;i<n;i++){ arr[i]=in.nextInt(); } for(i=0;i<n;i++){ long x=arr[i]; long y=(long)Math.sqrt(x); if(y*y!=x){ flag=1; //break; } } if(flag==0){ w.println("NO"); }else{ w.println("YES"); } } w.close(); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
8f5fd0af2b39f4cc1181ee65f5262714
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.*; public class Codeforces { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int t = Integer.parseInt(br.readLine()); while(t-->0) { int n = Integer.parseInt(br.readLine()); int arr[] = new int[n]; String inp[] = br.readLine().split(" "); for(int i = 0; i < n; ++i) arr[i] = Integer.parseInt(inp[i]); boolean flag = false; for(int i : arr) { if(i % Math.sqrt(i) != 0) { flag = true; break; } } if(flag) bw.write("YES\n"); else bw.write("NO\n"); } bw.flush(); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
4cc4398fcbf4472433c9f12f561d69ff
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.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { boolean f=false; int n=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i<n;i++) { arr[i]=sc.nextInt(); } for(int i=0;i<n;i++) { if(!isperfectSquare(arr[i])) { f=true; break; } } if(f) { System.out.println("YES"); } else { System.out.println("NO"); } } } public static boolean isperfectSquare(int number) { double sqrt=Math.sqrt(number); return ((sqrt - Math.floor(sqrt)) == 0); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
32fe92e3b3556120d22e50d0591297ad
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.Scanner; import java.util.*; import java.lang.*; import java.io.IOException; public class Code { //// public static void main(String[] args) throws IOException { try { System.setIn(new FileInputStream("input.txt")); System.setOut(new PrintStream(new FileOutputStream("output.txt"))); } catch (Exception e) { System.err.println("Error"); } // BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) Scanner sc= new Scanner(System.in); int t = sc.nextInt(); while(t--!=0) { // int h = sc.nextInt(); // int = sc.nextInt(); int n = sc.nextInt(); int[] a = new int[n]; int c1=0,c2=0; for(int i=0;i<n;i++) { a[i] = sc.nextInt(); if(!(Math.ceil((double)Math.sqrt(a[i])) == Math.floor((double)Math.sqrt(a[i])))) { c1++; } } if(c1>0) { System.out.println("YES"); } else { System.out.println("NO"); } // System.out.println(sum1-diff); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d0236be89560733c0db504cd4780c621
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 scn = new Scanner(System.in); long t = scn.nextLong(); for (int j = 1; j <= t; j++) { int n = scn.nextInt(); long[] arr = new long[n]; for (int i = 0; i < n; i++) { arr[i] = scn.nextLong(); } System.out.println(helper(arr)); } } public static String helper(long[] arr) { for (int i = 0; i < arr.length; i++) { int ceil = (int) Math.ceil(Math.sqrt(arr[i])); int floor = (int) Math.floor(Math.sqrt(arr[i])); if (ceil != floor) return "YES"; } return "NO"; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
0cd2a96b12054fa23fe709409742e873
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.math.BigInteger; import java.util.Scanner; public class p1 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int y=Integer.MIN_VALUE; int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); if(((long)Math.sqrt(a[i])*((long)Math.sqrt(a[i])))!=a[i]) { y=0; } } if(y==0) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f17f58d16518c648e1c494bf6a057a9d
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.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class B { public static void main(String[] args) { FastScanner fs=new FastScanner(); int T=fs.nextInt(); while (T-- > 0) { int n = fs.nextInt(); int[] a = fs.readArray(n); boolean b = false; for (int i = 0 ; i < n; i++) { double sq = Math.sqrt(a[i]); if ((sq - Math.floor(sq)) != 0.0) { System.out.println("YES"); b = true; break; } } if (!b) { System.out.println("NO"); } } } static void sort(int[] a) { ArrayList<Integer> l=new ArrayList<>(); for (int i:a) l.add(i); Collections.sort(l); for (int i=0; i<a.length; i++) a[i]=l.get(i); } static class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a=new int[n]; for (int i=0; i<n; i++) a[i]=nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
019d2c952a12c14569581569e2ae03f9
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 MyClass { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int a[]=new int[n]; String s="NO"; for(int i=0;i<n;i++) a[i]=sc.nextInt(); for(int i=0;i<n;i++) { int p=(int)Math.sqrt(a[i]); if(p*p!=a[i]) { s="YES"; break; } } System.out.println(s); } }}
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
10c0fdf0f86133310e202aa873c8f396
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.InputStreamReader; import java.util.StringTokenizer; public final class Main { public static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); } String next(){ while (st==null || !st.hasMoreElements()){ try{ st=new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } return st.nextToken(); } int nextInt(){ return Integer.parseInt(next()); } long nextLong(){ return Long.parseLong(next()); } double nextDouble(){ return Double.parseDouble(next()); } float nextFloat(){ return Float.parseFloat(next()); } String nextLine(){ String str=""; try{ str=br.readLine(); }catch (Exception e){ e.printStackTrace(); } return str; } } public static void main(String[] args) { FastReader in =new FastReader(); int t=in.nextInt(); while (t-->0){ int n=in.nextInt(); int[] a=new int[n]; String[] s=in.nextLine().split(" "); boolean flag=false; for (int i=0;i<n;i++){ a[i]= Integer.parseInt(s[i]); double k= Math.sqrt(a[i]); int x = (int)k; if(k!=x){ flag = true; break; } } if (flag) System.out.println("YES"); else System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
99630dee8853e70ee564915942192e01
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 whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner scn=new Scanner(System.in); int t=scn.nextInt(); while(t-->0){ int n=scn.nextInt(); int[] arr=new int[n]; for(int i=0;i<n;i++){ arr[i]=scn.nextInt(); } boolean found=false; for(int i=0;i<n;i++){ if((int)Math.ceil(Math.sqrt(arr[i]))!=(int)Math.floor(Math.sqrt(arr[i]))){ System.out.println("YES"); found=true; break; } } if(!found){ System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
2afc0b6410891c1aea9380cfd201390e
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
// Working program using Reader Class import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Q1 { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader(String file_name) throws IOException { din = new DataInputStream( new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String readLine() throws IOException { byte[] buf = new byte[64]; // line length int cnt = 0, c; while ((c = read()) != -1) { if (c == '\n') { if (cnt != 0) { break; } else { continue; } } buf[cnt++] = (byte)c; } return new String(buf, 0, cnt); } public int nextInt() throws IOException { int ret = 0; byte c = read(); while (c <= ' ') { c = read(); } boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() throws IOException { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') { while ((c = read()) >= '0' && c <= '9') { ret += (c - '0') / (div *= 10); } } if (neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din == null) return; din.close(); } } public static void main(String[] args) throws IOException { Reader s = new Reader(); int t=s.nextInt(); while(t-->0) { int n=s.nextInt(); int[] a=new int[n]; long ans=0; for(int i=0;i<n;i++) { a[i]=s.nextInt(); } for(int i=0;i<n;i++) { int temp=a[i]; int sqt=(int)Math.sqrt(a[i]); if(sqt*sqt != temp) { System.out.println("YES"); ans=1; break; } } if(ans==0)System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
7fefd3cbc3e6d945e28f48392c9f8701
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.util.LinkedList; import java.io.*; import java.math.*; public class Main { static class Pair{ int key; int value; Pair(int key,int value) { this.key=key; this.value=value; } int getKey(){ return this.key; } int getValue(){ return this.value; } } public static class SortbyKey implements Comparator<Pair> { public int compare(Pair a, Pair b){ return (a.key- b.key); } } public static boolean isPerfectSquare(double n) { double p= Math.sqrt(n); return ((p - Math.floor(p)) == 0); } public static void process()throws IOException { int n=ni(); double arr[]=new double[n]; int flag=0; for(int i=0;i<n;i++) { arr[i]=nd(); } for(int i=0;i<n;i++) { if(!isPerfectSquare(arr[i])) { flag=1; break; } } if(flag==1) pn("YES"); else pn("NO"); //int n=ni(),k=ni(); } static AnotherReader sc; static PrintWriter out; public static void main(String[]args)throws IOException { out = new PrintWriter(System.out); sc=new AnotherReader(); boolean oj = true; //PrintWriter out=new PrintWriter("output"); //oj = System.getProperty("ONLINE_JUDGE") != null; //if(!oj) sc=new AnotherReader(100); // int T=ni(); //while(T-->0) //process(); int i=1; int T=ni(); while(T-->0) // { // p("Case #"+i+": "); process(); // i++; // } long s = System.currentTimeMillis(); out.flush(); if(!oj) System.out.println(System.currentTimeMillis()-s+"ms"); System.out.close(); } static void sort(long arr[],int n) { shuffle(arr,n); Arrays.sort(arr); } static void shuffle(long arr[],int n) { Random r=new Random(); for(int i=0;i<n;i++) { long temp=arr[i]; int pos=i+r.nextInt(n-i); arr[i]=arr[pos]; arr[pos]=temp; } } static void pn(Object o){out.println(o);} static void p(Object o){out.print(o);} static void pni(Object o){out.println(o);System.out.flush();} static int ni()throws IOException{return sc.nextInt();} static long nl()throws IOException{return sc.nextLong();} static double nd()throws IOException{return sc.nextDouble();} static String nln()throws IOException{return sc.nextLine();} static String nn()throws IOException{return sc.next();} static int len(String s)throws IOException{return s.length();} static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);} static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);} static long bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));} static int[] iarr(int N)throws IOException{int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;} static long[] larr(int N)throws IOException{long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;} static boolean multipleTC=false; ///////////////////////////////////////////////////////////////////////////////////////////////////////// static class AnotherReader{BufferedReader br; StringTokenizer st; AnotherReader()throws FileNotFoundException{ br=new BufferedReader(new InputStreamReader(System.in));} AnotherReader(int a)throws FileNotFoundException{ br = new BufferedReader(new FileReader("input.txt"));} String next()throws IOException{ while (st == null || !st.hasMoreElements()) {try{ st = new StringTokenizer(br.readLine());} catch (IOException e){ e.printStackTrace(); }} return st.nextToken(); } int nextInt() throws IOException{ return Integer.parseInt(next());} long nextLong() throws IOException {return Long.parseLong(next());} double nextDouble()throws IOException { return Double.parseDouble(next()); } String nextLine() throws IOException{ String str = ""; try{ str = br.readLine();} catch (IOException e){ e.printStackTrace();} return str;}} ///////////////////////////////////////////////////////////////////////////////////////////////////////////// }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
c74d4dec4223e2663ab1f6c070251ec8
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; import java.util.Arrays; import java.util.HashMap; //import java.util.HashMap; //import java.util.Arrays; //import java.util.Stack; import java.lang.Math; public class solution { public static void main(String[] args) { Scanner s = new Scanner(System.in); int testcases = s.nextInt(); while(testcases-->0) { int n=s.nextInt(); int[] arr=new int[n]; for(int i=0;i<n;i++) { arr[i]=s.nextInt(); } boolean flag=false; for(int i=0;i<n;i++) { int a =(int)Math.sqrt(arr[i]); if(a*a!=arr[i]) { flag=true; break; } } if(flag) System.out.println("YES"); else System.out.println("NO"); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
aa482b697ef060585c33cb402ad45b56
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 a{ static Scanner sc = new Scanner(System.in); public static void solve(){ int len = sc.nextInt(); boolean pr = false; long [] tab = new long[len]; for(int i=0;i<len;i++){ tab[i] = sc.nextLong(); } for(int i=0;i<len;i++){ long l = (long)Math.sqrt(tab[i]); if(l*l!=tab[i]){ System.out.println("YES"); pr = true; break; } } if(!pr) System.out.println("NO"); } public static void main (String [] args){ int cases = sc.nextInt(); for(int i=1;i<=cases;i++){ //System.out.println("Case "+i+" : "); solve(); } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
024519ba5fe61dd85cc79578992c6c4b
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 Perfectly_Imperfect_Array { static boolean isPerfectSquare(int num) { long left = 1, right = num; while (left <= right) { long mid = (left + right) / 2; if (mid * mid == num) { return true; } if (mid * mid < num) { left = mid + 1; } else { right = mid - 1; } } return false; } 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]; boolean check=true; for (int i=0;i<n;i++){ arr[i]=sc.nextInt(); } for (int i=0;i<n;i++){ if (!isPerfectSquare(arr[i])){ check=false; break; } } if (check){ System.out.println("NO"); }else { System.out.println("YES"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
97e9e3c891a6261d74959ed3991faf72
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.*; public class Hackerrank { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t = sc.nextInt(); for(int i=0;i<t;i++) { int n = sc.nextInt(); boolean temp = false; int[] arr = new int[n]; for(int j=0;j<n;j++) { arr[j] =sc.nextInt(); int x = (int) Math.sqrt(arr[j]); if(x*x!=arr[j]) { temp = true; } } if(temp) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
d6058baccb689479520fa08bdb6e273d
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=(int)Math.sqrt(ar[i]); if(v*v!=ar[i]) { ps=false; break; } } if(!ps) System.out.println("YES"); else System.out.println("NO"); t--; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
f2c3a9dd6e46e39797f939e4cd4759c7
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 CF2308 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int testCases = scan.nextInt(); while(testCases>0){ int arrayLength = scan.nextInt(); int[] array = new int[arrayLength]; for(int i=0; i<arrayLength; i++){ array[i] = scan.nextInt(); } if(hasSquaredSubsequence(array)){ System.out.println("NO"); }else{ System.out.println("YES"); } testCases--; } } public static boolean hasSquaredSubsequence(int[] array){ for(int num : array){ double dNum = num; double root = Math.sqrt(dNum); if(root != (int)root){ return false; } } return true; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
5c771a25d040bcc49aa4ab001fb1b2d7
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 MyClass { public static void main(String args[]) { Scanner kb = new Scanner(System.in); int t = kb.nextInt(); while(t-- > 0) { int n = kb.nextInt(); int [] arr = new int[n]; for(int i=0;i<n;i++) { arr[i] = kb.nextInt(); } boolean flag = false; for(int i=0;i<n;i++) { if(!isPerfect(arr[i])) { //System.out.println("IN the if for: "+arr[i]); flag = true; break; } } if(flag) { System.out.println("YES"); } else { System.out.println("NO"); } } } public static boolean isPerfect(int n) { for(int i=1;i*i<=n;i++) { if(n%i==0 && n/i==i) { return true; } } return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
a005cd973ec047252f819348776871f8
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 sc = new Scanner(System.in); int t = sc.nextInt(), n, a[]; boolean k; while(t -- > 0){ k = false; n = sc.nextInt(); a = new int[n]; for(int i = 0; i < n; i ++){ a[i] = sc.nextInt(); if(Math.sqrt(a[i]) != (int)Math.sqrt(a[i])) k = true; } System.out.println(k ? "YES" : "NO"); } sc.close(); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
fdc26e53bb946ea176cfa1bc01dcb570
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 Practice { static boolean multipleTC = true; final static int mod = 1000000007; final static int mod2 = 998244353; final double E = 2.7182818284590452354; final double PI = 3.14159265358979323846; int MAX = 41000; int N = 40000; int dp[]; void pre() throws Exception { // dp = new int[N + 1]; // dp[0] = 1; // for (int a = 1; a <= N; a++) // if (reverse(a, 0) == a) { // for (int n = 0; n + a <= N; n++) { // dp[n + a] = (dp[n + a] + dp[n]) % mod; // } // } } int reverse(int a, int b) { return a == 0 ? b : reverse(a / 10, b * 10 + a % 10); } // All the best void solve(int TC) throws Exception { int n = ni(), arr[] = readArr(n); boolean has = false; for(int i:arr) { if(StrictMath.sqrt(i) % 1.0 != 0) { has = true; } } if(has) { pn("YES"); }else { pn("NO"); } } public static long gcd(long a, long b) { if (a > b) a = (a + b) - (b = a); if (a == 0L) return b; return gcd(b % a, a); } double dist(int x1, int y1, int x2, int y2) { double a = x1 - x2, b = y1 - y2; return Math.sqrt((a * a) + (b * b)); } int[] readArr(int n) throws Exception { int arr[] = new int[n]; for (int i = 0; i < n; i++) { arr[i] = ni(); } return arr; } void sort(int arr[], int left, int right) { ArrayList<Integer> list = new ArrayList<>(); for (int i = left; i <= right; i++) list.add(arr[i]); Collections.sort(list); for (int i = left; i <= right; i++) arr[i] = list.get(i - left); } void sort(int arr[]) { ArrayList<Integer> list = new ArrayList<>(); for (int i = 0; i < arr.length; i++) list.add(arr[i]); Collections.sort(list); for (int i = 0; i < arr.length; i++) arr[i] = list.get(i); } public long max(long... arr) { long max = arr[0]; for (long itr : arr) max = Math.max(max, itr); return max; } public int max(int... arr) { int max = arr[0]; for (int itr : arr) max = Math.max(max, itr); return max; } public long min(long... arr) { long min = arr[0]; for (long itr : arr) min = Math.min(min, itr); return min; } public int min(int... arr) { int min = arr[0]; for (int itr : arr) min = Math.min(min, itr); return min; } public long sum(long... arr) { long sum = 0; for (long itr : arr) sum += itr; return sum; } public long sum(int... arr) { long sum = 0; for (int itr : arr) sum += itr; return sum; } String bin(long n) { return Long.toBinaryString(n); } String bin(int n) { return Integer.toBinaryString(n); } static int bitCount(int x) { return x == 0 ? 0 : (1 + bitCount(x & (x - 1))); } static void dbg(Object... o) { System.err.println(Arrays.deepToString(o)); } int bit(long n) { return (n == 0) ? 0 : (1 + bit(n & (n - 1))); } int abs(int a) { return (a < 0) ? -a : a; } long abs(long a) { return (a < 0) ? -a : a; } void p(Object o) { out.print(o); } void pn(Object o) { out.println(o); } void pni(Object o) { out.println(o); out.flush(); } void pn(int[] arr) { int n = arr.length; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append(arr[i] + " "); } pn(sb); } void pn(long[] arr) { int n = arr.length; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append(arr[i] + " "); } pn(sb); } String n() throws Exception { return in.next(); } String nln() throws Exception { return in.nextLine(); } int ni() throws Exception { return Integer.parseInt(in.next()); } long nl() throws Exception { return Long.parseLong(in.next()); } double nd() throws Exception { return Double.parseDouble(in.next()); } public static void main(String[] args) throws Exception { new Practice().run(); } FastReader in; PrintWriter out; void run() throws Exception { in = new FastReader(); out = new PrintWriter(System.out); int T = (multipleTC) ? ni() : 1; pre(); for (int t = 1; t <= T; t++) solve(t); out.flush(); out.close(); } class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(String s) throws Exception { br = new BufferedReader(new FileReader(s)); } String next() throws Exception { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { throw new Exception(e.toString()); } } return st.nextToken(); } String nextLine() throws Exception { String str = ""; try { str = br.readLine(); } catch (IOException e) { throw new Exception(e.toString()); } return str; } } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
bb126c456d5422bb6c771b8006e6dfe1
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.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; /** * * @author eslam */ public class IceCave { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } static FastReader input = new FastReader(); static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws IOException { int t = input.nextInt(); loop: while (t-- > 0) { int n = input.nextInt(); int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = input.nextInt(); } for (int i = 0; i < n; i++) { int x = (int) Math.sqrt(a[i]); if (x * x != a[i]) { log.write("YES\n"); continue loop; } } log.write("NO\n"); } log.flush(); } public static long binaryToDecimal(String w) { long r = 0; long l = 0; for (int i = w.length() - 1; i > -1; i--) { long x = (w.charAt(i) - '0') * (long) Math.pow(2, l); r = r + x; l++; } return r; } public static String decimalToBinary(long n) { String w = ""; while (n > 0) { w = n % 2 + w; n /= 2; } return w; } public static boolean isSorted(int[] a) { for (int i = 0; i < a.length - 1; i++) { if (a[i] > a[i + 1]) { return false; } } return true; } public static void print(int a[]) throws IOException { for (int i = 0; i < a.length; i++) { log.write(a[i] + " "); } log.write("\n"); } public static void read(int[] a) { for (int i = 1; i < a.length; i++) { a[i] = input.nextInt(); } } static class pair { int x; int y; public pair(int x, int y) { this.x = x; this.y = y; } public String toString() { return x + " " + y; } } public static long LCM(long x, long y) { return (x * y) / GCD(x, y); } public static long GCD(long x, long y) { if (y == 0) { return x; } return GCD(y, x % y); } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
758bfbcb55b95d564866f3e1bd96002b
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.lang.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i=0;i<n;i++){ int a = sc.nextInt(); int arr[] = new int[a]; int cnt=0; for(int j=0;j<a;j++){ arr[j] = sc.nextInt(); if(perfectsquare(arr[j])){ cnt++; } } // System.out.println(cnt); if(cnt>=a){ System.out.println("NO"); } else{ System.out.println("YES"); } } } public static String remVowel(String str) { return str.replaceAll("[aeiouAEIOU]", ""); } public static String Ssort(String s) { char tempArray[] = s.toCharArray(); Arrays.sort(tempArray); return new String(tempArray); } public static int smallest(int x, int y,int z ) { return Math.min(Math.min(x, y), z); } public static int largest(int x,int y, int z) { return Math.max(Math.max(x, y), z); } public static int average(int x,int y,int z) { return(x+y+z)/3; } public static int sumdigit(long x) { int result = 0; while(x>0){ result+=x%10; x/=10; } return result; } public static String isPowerOfTwo(long n) { if (n == 0) return ("Yes"); while (n != 1) { if (n % 2 != 0) return ("Yes"); n = n / 2; } return ("No"); } public static char[] swap(String s) { char ch[] = s.toCharArray(); char temp = ch[0]; ch[0] = ch[s.length()-1]; ch[s.length()-1] = temp; return ch; } public static boolean perfectsquare(int x) { if (x >= 0) { int sr = (int)Math.sqrt(x); return ((sr * sr) == x); } return false; } }
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 11
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
ef0d9d2fb8e0d1eeb0629e1f5394b4af
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 boolean perfect(int x) { int i = 0; while(i * i < x) { ++i; } if(i * i == x) { return true; } else { return false; } } public static void main(String[] args) { Scanner input = new Scanner(System.in); int testCases= input.nextInt(); for(int i = 0; i < testCases; ++i) { int length = input.nextInt();; boolean square = true; for(int j = 0; j < length; ++j) { int element=input.nextInt(); if(square && !perfect(element)) { square = false; } } if(square) { System.out.println("No"); } else { System.out.println("Yes"); } } } }
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
ff5fec316666b2c427b32058c9881cd4
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.math.*; import java.util.*; public class D { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } static FastReader s = new FastReader(); static PrintWriter out = new PrintWriter(System.out); private static int[] rai(int n) { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = s.nextInt(); } return arr; } private static int[][] rai(int n, int m) { int[][] arr = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { arr[i][j] = s.nextInt(); } } return arr; } private static long[] ral(int n) { long[] arr = new long[n]; for (int i = 0; i < n; i++) { arr[i] = s.nextLong(); } return arr; } private static long[][] ral(int n, int m) { long[][] arr = new long[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { arr[i][j] = s.nextLong(); } } return arr; } private static int ri() { return s.nextInt(); } private static long rl() { return s.nextLong(); } private static String rs() { return s.next(); } // int g; public static void main(String[] args) { // TODO Auto-generated method stub FastReader sc=new FastReader(); int t,n,m=0,i=0,j=0,k=0,c=0,fg=0,p=0,q=0,tm=0,a=0,b=0,x=0,y=0,z=0,max=-1,min=Integer.MAX_VALUE; String str; long sum=0,ans=0,g=1; BigInteger f=BigInteger.valueOf(1); // System.out.println(""); t=sc.nextInt(); while(t-->0) { n=sc.nextInt(); int arr[]=new int[n]; for(i=0;i<n;i++) { arr[i]=sc.nextInt(); if(arr[i]!=(int)Math.sqrt(arr[i])*Math.sqrt(arr[i])) fg=1; // System.out.println(arr[i]+" "+Math.sqrt(arr[i])*Math.sqrt(arr[i])); } if(fg==1) System.out.println("YES"); else System.out.println("NO"); fg=0; } } }
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
9d21d972e5067e240a1ec54a34231b33
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.io.PrintWriter; import java.util.*; public class A { //a public static void main(String[] args) { FastScanner fs = new FastScanner(); int test = fs.nextInt(); test: for (int tt = 0; tt < test; tt++) { int n = fs.nextInt(); int[] ar = fs.readArray(n); boolean notSq =false; for(int i : ar){ if(!isSquare(i))notSq=true; } if(notSq)System.out.println("YES"); else System.out.println("NO"); } } private static boolean isSquare(long x) { long y = (long) Math.sqrt(x); while (y*y>x)--y; while (y*y<x)++y; return y*y==x; } static void sort(int[] s) { ArrayList<Integer> list = new ArrayList<>(); for (int i : s) list.add(i); Collections.sort(list); for (int i = 0; i < s.length; i++) s[i] = list.get(i); } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = nextInt(); } return arr; } List<Integer> readList(int n) { List<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) { list.add(nextInt()); } return list; } long nextLong() { return Long.parseLong(next()); } } }
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
71d87332a003e9f968258701ac3a4628
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.io.PrintWriter; import java.util.*; public class A { public static void main(String[] args) { FastScanner fs = new FastScanner(); int test = fs.nextInt(); test: for (int tt = 0; tt < test; tt++) { int n = fs.nextInt(); int[] ar = fs.readArray(n); boolean notSq =false; for(int i : ar){ if(!isSquare(i))notSq=true; } if(notSq)System.out.println("YES"); else System.out.println("NO"); } } private static boolean isSquare(long x) { long y = (long) Math.sqrt(x); while (y*y>x)--y; while (y*y<x)++y; return y*y==x; } static void sort(int[] s) { ArrayList<Integer> list = new ArrayList<>(); for (int i : s) list.add(i); Collections.sort(list); for (int i = 0; i < s.length; i++) s[i] = list.get(i); } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = nextInt(); } return arr; } List<Integer> readList(int n) { List<Integer> list = new ArrayList<>(); for (int i = 0; i < n; i++) { list.add(nextInt()); } return list; } long nextLong() { return Long.parseLong(next()); } } }
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
5c9461978ec73829dc588ad19c3b5475
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.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); solve(in, out); out.close(); } static String reverse(String s) { return (new StringBuilder(s)).reverse().toString(); } static void sieveOfEratosthenes(int n, int factors[]) { n=1000000001; factors[1]=1; for(int p = 2; p*p <=n; p++) { if(factors[p] == 0) { factors[p]=p; for(int i = p*p; i <= n; i += p) factors[i] = p; } } } static void sort(int ar[]) { int n = ar.length; ArrayList<Integer> a = new ArrayList<>(); for (int i = 0; i < n; i++) a.add(ar[i]); Collections.sort(a); for (int i = 0; i < n; i++) ar[i] = a.get(i); } static void sort1(long ar[]) { int n = ar.length; ArrayList<Long> a = new ArrayList<>(); for (int i = 0; i < n; i++) a.add(ar[i]); Collections.sort(a); for (int i = 0; i < n; i++) ar[i] = a.get(i); } static long ncr(long n, long r, long mod) { if (r == 0) return 1; long val = ncr(n - 1, r - 1, mod); val = (n * val) % mod; val = (val * modInverse(r, mod)) % mod; return val; } public static int convert(String a, String b) { int T=0; if(b.charAt(0)=='P') { if(a.charAt(0)=='1'&&a.charAt(1)=='2') T=12; else T=(a.charAt(0)-'0')*10+(a.charAt(1)-'0')+12; } else if(b.charAt(0)=='A') { if(a.charAt(0)=='1'&&a.charAt(1)=='2') T=0; else T=(a.charAt(0)-'0')*10+(a.charAt(1)-'0'); } T=T*100+(a.charAt(3)-'0')*10+(a.charAt(4)-'0'); return T; } static boolean areBracketsBalanced(String expr) { // Using ArrayDeque is faster than using Stack class Deque<Character> stack = new ArrayDeque<Character>(); // Traversing the Expression for (int i = 0; i < expr.length(); i++) { char x = expr.charAt(i); if (x == '(' || x == '[' || x == '{') { // Push the element in the stack stack.push(x); continue; } // IF current current character is not opening // bracket, then it must be closing. So stack // cannot be empty at this point. if (stack.isEmpty()) return false; char check; switch (x) { case ')': check = stack.pop(); if (check == '{' || check == '[') return false; break; case '}': check = stack.pop(); if (check == '(' || check == '[') return false; break; case ']': check = stack.pop(); if (check == '(' || check == '{') return false; break; } } // Check Empty Stack return (stack.isEmpty()); } public static int hr(String s) { int hh=0; hh=(s.charAt(0)-'0')*10+(s.charAt(1)-'0'); return hh; } public static int mn(String s) { int mm=0; mm=(s.charAt(3)-'0')*10+(s.charAt(4)-'0'); return mm; } /* * public static void countNumberOfPrimeFactors(){ boolean flag[]=new * boolean[N]; Arrays.fill(flag,true); for(int i=2;i<N;i++){ if(flag[i]){ * for(int j=i;j<N;j+=i) { prime[j]++; flag[j]=false; } } } // prime[1]=1; } */ public static String rev(String s) { char[] temp=s.toCharArray(); for(int i=0;i<s.length()/2;i++) { char tmp=temp[i]; temp[i]=temp[s.length()-1-i]; temp[s.length()-1-i]=tmp; } String str=""; for(char ch: temp) { str+=ch; } return str; } static boolean isP(String str) { // Pointers pointing to the beginning // and the end of the string int i = 0, j = str.length() - 1; // While there are characters to compare while (i < j) { // If there is a mismatch if (str.charAt(i) != str.charAt(j)) return false; // Increment first pointer and // decrement the other i++; j--; } // Given string is a palindrome return true; } public static boolean isSorted(List<Integer> l) { int n=l.size(),i=0; for(i=1;i<l.size();i++) { if(l.get(i-1)<l.get(i)) return false; } return true; } public static boolean ln(long n, int c) { int l=0; long t=n; while(t!=0) { t/=10; l++; } return l==c; } public static void solve(InputReader sc, PrintWriter pw) { int t=sc.nextInt(); while(t-->0) { boolean f=true; int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) a[i]=sc.nextInt(); for(int i=0;i<n;i++) { int sq=(int)Math.sqrt(a[i]); if(sq*sq!=a[i]) {f=false; } } if(!f) pw.print("YES"); else pw.print("NO"); pw.print("\n"); } } static class Pair1 { long a; long b; Pair1(long a, long b) { this.a = a; this.b = b; } } static class Pair implements Comparable<Pair> { int a; int b; Pair(int a, int b) { this.a = a; this.b = b; } public int compareTo(Pair p) { if(a!=p.a) return p.a-a; return b-p.b; } } static boolean isPrime(long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } static long fast_pow(long base, long n, long M) { if (n == 0) return 1; if (n == 1) return base % M; long halfn = fast_pow(base, n / 2, M); if (n % 2 == 0) return (halfn * halfn) % M; else return (((halfn * halfn) % M) * base) % M; } static long modInverse(long n, long M) { return fast_pow(n, M - 2, M); } public static int LowerBound(int a[], int x) { int l=-1,r=a.length; while(l+1<r) { int m=(l+r)>>>1; if(a[m]>=x) r=m; else l=m; } return r; } public static int UpperBound(int a[], int x) { int l=-1, r=a.length; while(l+1<r) { int m=(l+r)>>>1; if(a[m]<=x) l=m; else r=m; } return l+1; } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String nextLine() { return null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } } }
Java
["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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
0181875281c3288010dce53ada1f2039
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.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); solve(in, out); out.close(); } static String reverse(String s) { return (new StringBuilder(s)).reverse().toString(); } static void sieveOfEratosthenes(int n, int factors[]) { n=1000000001; factors[1]=1; for(int p = 2; p*p <=n; p++) { if(factors[p] == 0) { factors[p]=p; for(int i = p*p; i <= n; i += p) factors[i] = p; } } } static void sort(int ar[]) { int n = ar.length; ArrayList<Integer> a = new ArrayList<>(); for (int i = 0; i < n; i++) a.add(ar[i]); Collections.sort(a); for (int i = 0; i < n; i++) ar[i] = a.get(i); } static void sort1(long ar[]) { int n = ar.length; ArrayList<Long> a = new ArrayList<>(); for (int i = 0; i < n; i++) a.add(ar[i]); Collections.sort(a); for (int i = 0; i < n; i++) ar[i] = a.get(i); } static long ncr(long n, long r, long mod) { if (r == 0) return 1; long val = ncr(n - 1, r - 1, mod); val = (n * val) % mod; val = (val * modInverse(r, mod)) % mod; return val; } public static int convert(String a, String b) { int T=0; if(b.charAt(0)=='P') { if(a.charAt(0)=='1'&&a.charAt(1)=='2') T=12; else T=(a.charAt(0)-'0')*10+(a.charAt(1)-'0')+12; } else if(b.charAt(0)=='A') { if(a.charAt(0)=='1'&&a.charAt(1)=='2') T=0; else T=(a.charAt(0)-'0')*10+(a.charAt(1)-'0'); } T=T*100+(a.charAt(3)-'0')*10+(a.charAt(4)-'0'); return T; } static boolean areBracketsBalanced(String expr) { // Using ArrayDeque is faster than using Stack class Deque<Character> stack = new ArrayDeque<Character>(); // Traversing the Expression for (int i = 0; i < expr.length(); i++) { char x = expr.charAt(i); if (x == '(' || x == '[' || x == '{') { // Push the element in the stack stack.push(x); continue; } // IF current current character is not opening // bracket, then it must be closing. So stack // cannot be empty at this point. if (stack.isEmpty()) return false; char check; switch (x) { case ')': check = stack.pop(); if (check == '{' || check == '[') return false; break; case '}': check = stack.pop(); if (check == '(' || check == '[') return false; break; case ']': check = stack.pop(); if (check == '(' || check == '{') return false; break; } } // Check Empty Stack return (stack.isEmpty()); } public static int hr(String s) { int hh=0; hh=(s.charAt(0)-'0')*10+(s.charAt(1)-'0'); return hh; } public static int mn(String s) { int mm=0; mm=(s.charAt(3)-'0')*10+(s.charAt(4)-'0'); return mm; } /* * public static void countNumberOfPrimeFactors(){ boolean flag[]=new * boolean[N]; Arrays.fill(flag,true); for(int i=2;i<N;i++){ if(flag[i]){ * for(int j=i;j<N;j+=i) { prime[j]++; flag[j]=false; } } } // prime[1]=1; } */ public static String rev(String s) { char[] temp=s.toCharArray(); for(int i=0;i<s.length()/2;i++) { char tmp=temp[i]; temp[i]=temp[s.length()-1-i]; temp[s.length()-1-i]=tmp; } String str=""; for(char ch: temp) { str+=ch; } return str; } static boolean isP(String str) { // Pointers pointing to the beginning // and the end of the string int i = 0, j = str.length() - 1; // While there are characters to compare while (i < j) { // If there is a mismatch if (str.charAt(i) != str.charAt(j)) return false; // Increment first pointer and // decrement the other i++; j--; } // Given string is a palindrome return true; } public static boolean isSorted(List<Integer> l) { int n=l.size(),i=0; for(i=1;i<l.size();i++) { if(l.get(i-1)<l.get(i)) return false; } return true; } public static boolean ln(long n, int c) { int l=0; long t=n; while(t!=0) { t/=10; l++; } return l==c; } public static void solve(InputReader sc, PrintWriter pw) { int t=sc.nextInt(); while(t-->0) { boolean f=true; int n=sc.nextInt(); for(int i=0;i<n;i++) { int a=sc.nextInt(); int sq=(int)Math.sqrt(a); if(sq*sq!=a) f=false; } if(!f) pw.print("YES"); else pw.print("NO"); pw.print("\n"); } } static class Pair1 { long a; long b; Pair1(long a, long b) { this.a = a; this.b = b; } } static class Pair implements Comparable<Pair> { int a; int b; Pair(int a, int b) { this.a = a; this.b = b; } public int compareTo(Pair p) { if(a!=p.a) return p.a-a; return b-p.b; } } static boolean isPrime(long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } static long fast_pow(long base, long n, long M) { if (n == 0) return 1; if (n == 1) return base % M; long halfn = fast_pow(base, n / 2, M); if (n % 2 == 0) return (halfn * halfn) % M; else return (((halfn * halfn) % M) * base) % M; } static long modInverse(long n, long M) { return fast_pow(n, M - 2, M); } public static int LowerBound(int a[], int x) { int l=-1,r=a.length; while(l+1<r) { int m=(l+r)>>>1; if(a[m]>=x) r=m; else l=m; } return r; } public static int UpperBound(int a[], int x) { int l=-1, r=a.length; while(l+1<r) { int m=(l+r)>>>1; if(a[m]<=x) l=m; else r=m; } return l+1; } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String nextLine() { return null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } } }
Java
["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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
96789c3c96a367558ba4a364bbab227f
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.InputStreamReader; import java.io.IOException; import java.math.BigInteger; public class perfectly_imperfectly_square { public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); try { int t=Integer.parseInt(br.readLine()); while(t-->0) { int n=Integer.parseInt(br.readLine()); String temp[]=br.readLine().split(" "); int arr[]=new int[n]; for(int i=0;i<temp.length;i++) { arr[i]=Integer.parseInt(temp[i]); } boolean flag=false; for(int i:arr) { int num=i; int val=(int)Math.sqrt(num); if((val*val)!=num) { flag=true; } } if(flag) { System.out.println("YES"); } else { System.out.println("NO"); } } } catch(Exception e) { } } }
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output
PASSED
c5a93f4e18b189575ce5741a6dbd69ce
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 Q1 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t--!=0) { int n = s.nextInt(); int flag=0; while(n--!=0) { int c = s.nextInt(); int ans = (int)(Math.sqrt(c)); if(ans*ans!=c) { flag=1; } } if(flag==1) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
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 $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.
800
If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".
standard output