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 | 609809b3a1150e587ce58e66604d961f | 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 Aa {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
int n = 0;
int a = 0;
int s = 0;
int c = 0;
for(int i=1;i<=t;i++){
n = scan.nextInt();
for(int j=1;j<=n;j++){
a = scan.nextInt();
s = (int)Math.sqrt(a);
if(s*s != a) c++;
}
if(c>0) System.out.println("YES");
else System.out.println("NO");
c=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 | 784b975d6f5033807d2f2153879edbbd | 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 in = new Scanner(System.in);
int t = in.nextInt();
while(t-->0){
int n = in.nextInt();
int a[] = new int[n];
for(int i = 0; i < n; i++){
a[i] = in.nextInt();
}
boolean flag = true;
for(int i = 0; i < n; i++){
long sqrt = (long)Math.sqrt(a[i]);
if(sqrt*sqrt != a[i]){
System.out.println("YES");
flag = false;
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 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 | b2fa78f88b883ca96af00e9d321f78ff | 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.io.*;
import java.util.*;
public class Setup {
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static long nextLong() throws IOException {
return Long.parseLong(next());
}
private static String next() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
static BufferedReader br;
static StringTokenizer st;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
Scanner scn=new Scanner(System.in);
int t = nextInt();
while (t-- > 0) {
int n=nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++) {
arr[i]=nextInt();
}
// long m=1;
boolean c=true;
for(int i=0;i<n;i++) {
// double a=Math.sqrt(arr[i]);
// double b=arr[i];
// System.out.println(b);
// if(a*a!=b) {
// c=false;
// break;
// }
if(!isPerfectSquare(arr[i])) {
c=false;
break;
}
}
if(c) {
bw.append("NO"+"\n");
}else {
bw.append("YES"+"\n");
}
}
bw.close();
}
public static boolean isPerfectSquare(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 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 | 0f48326050f14d642890709f4d70c34a | 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 | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
//Keshav Agarwal
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
static void reverse(int a[], int n)
{
int[] b = new int[n];
int j = n;
for (int i = 0; i < n; i++) {
b[j - 1] = a[i];
j = j - 1;
}
for (int k = 0; k < n; k++) {
System.out.print(b[k]+" ");
}
}
public int gcd(int a,int b) {
if(b==0) {
return a;
}
return gcd(b,a%b);
}
static void print(int a[], int n){
for(int i=0;i<n;i++){
System.out.print(a[i]+" ");
}
}
public static boolean PerfectSquare(int n) {
int squareroot=(int)Math.sqrt(n);
if(squareroot*squareroot==n) {
return true;
}else {
return false;
}
}
static boolean checkPerfectSquare(double number)
{
double sqrt=Math.sqrt(number);
return ((sqrt - Math.floor(sqrt)) == 0);
}
public static void main(String[] args)
{
FastReader scn = new FastReader();
int t=scn.nextInt();
while(t-->0){
int n=scn.nextInt();
int []arr=new int[n];
//int []a=new int[n];
for(int i=0;i<n;i++){
arr[i]=scn.nextInt();
}
boolean flag=true;
for(int i=0;i<n;i++) {
if(PerfectSquare(arr[i])==false){
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 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 | 2147adcb02db913709384fee3a3bad8f | 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 | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
//Keshav Agarwal
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
static void reverse(int a[], int n)
{
int[] b = new int[n];
int j = n;
for (int i = 0; i < n; i++) {
b[j - 1] = a[i];
j = j - 1;
}
for (int k = 0; k < n; k++) {
System.out.print(b[k]+" ");
}
}
public int gcd(int a,int b) {
if(b==0) {
return a;
}
return gcd(b,a%b);
}
static void print(int a[], int n){
for(int i=0;i<n;i++){
System.out.print(a[i]+" ");
}
}
public static boolean PerfectSquare(int n) {
int squareroot=(int)Math.sqrt(n);
if(squareroot*squareroot==n) {
return true;
}else {
return false;
}
}
static boolean checkPerfectSquare(double number)
{
double sqrt=Math.sqrt(number);
return ((sqrt - Math.floor(sqrt)) == 0);
}
public static void main(String[] args)
{
FastReader scn = new FastReader();
int t=scn.nextInt();
while(t-->0){
int n=scn.nextInt();
int []arr=new int[n];
//int []a=new int[n];
for(int i=0;i<n;i++){
arr[i]=scn.nextInt();
}
boolean flag=true;
for(int i=0;i<n;i++) {
if(checkPerfectSquare(arr[i])==false){
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 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 | de33e386934a7a824cb29d34164e32ec | train_110.jsonl | 1618839300 | Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
int n = sc.nextInt();
int arr[] = new int[n];
for(int i=0;i<n;i++)
{
arr[i] = sc.nextInt();
}
int flag = 0;
for(int i=0;i<n;i++)
{
if(Math.pow(Math.floor(Math.sqrt(arr[i])),2) != arr[i])
{
flag = 1;
break;
}
}
if(flag == 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 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 | db538c1c86ea3764515683248dc36ade | 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 codechef; // don't place package name! */
import java.io.*;
import java.lang.*;
import java.util.*;
import java.util.Collection;
import static java.lang.Math.*;
public class Main implements Runnable
{
public void run()
{
InputReader s = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
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();
}
int count = 0;
for(int i=0;i<n;i++)
{
int root = (int)Math.sqrt(arr[i]);
if(root * root != arr[i])
{
count++;
}
}
if(count != 0)
{
out.println("YES");
}
else
{
out.println("NO");
}
}
out.close();
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;;
private 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);
}
}
public static void main(String args[]) throws Exception {
new Thread(null, new Main(),"Main",1<<26).start();
}
}
| 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 | bc96380edd629a56778ed1e06f53c8d5 | 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 PerfectImperfectArray {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
if (t < 1 || t > 100) return;
for (int i = 0; i < t * 2; i += 2) {
int n = Integer.parseInt(br.readLine());
if (n < 1 || n > 100) return;
StringTokenizer tk = new StringTokenizer(br.readLine());
int[] arr = new int[n];
boolean hasImperfectSq = false;
for (int j = 0; j < n; j++) {
arr[j] = Integer.parseInt(tk.nextToken());
if (arr[j] < 1 || arr[j] > 10000) return;
int sq = (int) Math.sqrt(arr[j]);
if (sq * sq != arr[j]) {
hasImperfectSq = true;
break;
}
}
if (hasImperfectSq) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
br.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 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 | 49a490683fc81db8baae2cc85503fd5e | 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 TestMain {
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 void solve(FastReader fr) {
// FastReader fr = new FastReader();
int n = fr.nextInt();
boolean found = false;
// System.out.println("N is" + n);
int arr[] = new int[n];
for(int i=0; i<n; ++i){
arr[i] = fr.nextInt();
}
for(int i=0; i<n; ++i){
int element = arr[i];
if(element == 1){
continue;
}
boolean psquare = false;
for(int k=1; k<= element/2; ++k){
if(k*k == element){
psquare = true;
break;
}
}
if(!psquare){
found = true;
}
}
if(found){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
public static void main(String[] args) {
int tc;
FastReader fr = new FastReader();
tc = fr.nextInt();
while (tc>=1) {
new TestMain().solve(fr);
tc--;
}
}
}
| 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 | d9ea10527cfc5ac73e44ccbfdc81684c | 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[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine()); int flag=0;
for(int xyz=0; xyz<t ;xyz++)
{
flag=0;
int n=Integer.parseInt(br.readLine());
int arr[]=new int[n];
String str=br.readLine();
StringTokenizer st=new StringTokenizer(str," ");
for(int j=0; j<n; j++)
{
arr[j]=Integer.parseInt(st.nextToken());
}
long sr=0;
for(int j=0; j<n; j++)
{
sr=(long)Math.sqrt(arr[j]);
if(sr*sr!=arr[j])
{flag=1;
break;
}
}
if(flag==1)
{
System.out.print("YES");
}
else
System.out.print("NO");
System.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 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 | 40e4d794aa7c1265c609485b8b0e379f | 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 codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
boolean flag=true;
while(n-->0){
int k=sc.nextInt();
if(Math.sqrt(k)!=(int)Math.sqrt(k) && flag){
System.out.println("YES");
flag=false;
}
}
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 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 | 3c0a8e41be396b4b45e31eadc1098d4b | 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 A {
public static void main(String args[]) throws IOException {
FastReader sc = new FastReader();
PrintWriter out = new PrintWriter(System.out);
int tc, i, j;
String s;
char p;
tc = sc.nextInt();
while (tc-- > 0) {
int n = sc.nextInt();
int arr[] = sc.readArray(n);
long prod=1;
boolean flag=false;
int count=0;
for (i = 0; i < n; i++) {
int temp= (int)Math.sqrt(arr[i]);
if ((temp*temp)!=arr[i]){
flag=true;
break;
}
}
if (!flag)
out.println("NO");
else
out.println("YES");
}
out.close();
}
/*--------------------------------------------------------
----------------------------------------------------------*/
//Pair Class
public static class Pair implements Comparable<Pair> {
int x, y;
Pair(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public int compareTo(Pair o) {
return this.x - o.x;
}
}
/*
FASTREADER
*/
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;
}
/*DEFINED BY ME*/
//READING ARRAY
int[] readArray(int n) {
int arr[] = new int[n];
for (int i = 0; i < n; i++)
arr[i] = nextInt();
return arr;
}
//COLLECTIONS SORT
void sort(int arr[]) {
ArrayList<Integer> l = new ArrayList<>();
for (int i : arr)
l.add(i);
Collections.sort(l);
for (int i = 0; i < arr.length; i++)
arr[i] = l.get(i);
}
//EUCLID'S GCD
int gcd(int a, int b) {
if (b != 0)
return gcd(b, a % b);
else
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 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 | eb110e7f6b48ff8dd631cb1d87ca536c | 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.StringTokenizer;
public class A_Perfectly_Imperfect_Array {
static Scanner in=new Scanner();
static PrintWriter out=new PrintWriter(System.out);
static int testCase,n;
static long a[];
static boolean isPerfectSquare(long x)
{
if (x >= 0) {
long sr = (long) Math.sqrt(x);
return ((sr * sr) == x);
}
return false;
}
static void solve(){
long mul=1,psq=0,psqn=0;
for(long i: a){
if( !isPerfectSquare(i) ){
out.println("YES");
out.flush();
return;
}
}
out.println("NO");
out.flush();
}
public static void main(String[] amit) throws IOException {
testCase=in.nextInt();
for(int t=0;t<testCase;t++){
n=in.nextInt();
a=new long[n];
for(int i=0;i<n;i++){
a[i]=in.nextLong();
}
solve();
}
}
static class Scanner{
BufferedReader in;
StringTokenizer st;
public Scanner() {
in=new BufferedReader( new InputStreamReader( System.in ) );
}
String next() throws IOException{
while( st==null || !st.hasMoreElements() ){
st=new StringTokenizer( in.readLine() );
}
return st.nextToken();
}
String nextLine() throws IOException{
return in.readLine();
}
int nextInt() throws IOException{
return Integer.parseInt( next() );
}
long nextLong() throws IOException{
return Long.parseLong( next() );
}
double nextDouble() throws IOException{
return Double.parseDouble( next() );
}
}
}
/*
2
3
1 5 4
2
100 10000
*/
/*
1
5
1 2 3 4 5
*/
/*
1
2
1444 5452
*/ | 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 | e9c8561af2e0a4102002f4e7bdf48ecb | 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;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(bf.readLine()); if (t<1 || t>100) System.exit(0);
for (int z = 0; z < t; z++) {
int n = Integer.parseInt(bf.readLine()); if (n<1 || n>100) System.exit(0);
String[] values = bf.readLine().split(" ");
boolean answered = false;
for (int i = 0; i < n; i++) {
int holder = Integer.parseInt(values[i]);if (holder<1 || holder>10000) System.exit(0);
if(isPerfectSquare(holder))continue;
else {
System.out.println("YES");
answered = true;
break;
}
}
if (!answered) System.out.println("NO");
}
}
static boolean isPerfectSquare(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 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 | cd9a12c8c184dd47f3e55be07470aac4 | 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 A {
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];
int flag=0;
double b[]=new double[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
b[i]=(double) a[i];
}
for(int i=0;i<n;i++)
{
if(!isPerfectSquare(a[i]))
{
flag=1;
break;
}
}
if(flag==1)
System.out.println("YES");
else
System.out.println("NO");
}
}
static boolean isPerfectSquare(int 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 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 | 7750e1e0a86fcd69f0fda6617d909530 | 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 Demo {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// A.
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();
int cnt=0;
for(int i=0; i<n; i++) {
int x = a[i];
// System.out.println(x);
for(int j=1; j<=x; j++) {
// System.out.println(j*j+" "+x);
if(j*j==x) {
++cnt; break;
}
else if(j*j>x) {
break;
}
}
}
if(cnt==n) 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 | 9ec5d362bf47e7796aa0c3aeabaa1698 | 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.awt.image.AreaAveragingScaleFilter;
import java.io.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
public class Pratice {
final long mod = 1000000007;
static StringBuilder sb = new StringBuilder();
static int xn = (int) (2e5 + 10);
static long ans;
// calculate sqrt and cuberoot
static Set<Long> set=new TreeSet<>();
static
{
long n=1000000001;
for(int i=1;i*i<=n;i++)
{
long x=i*i;
set.add(x);
}
// for(int i=1;i*i*i<=n;i++)
// {
// long x=i*i*i;
// set.add(x);
// }
}
public static void main(String[] args) throws IOException {
Reader reader = new Reader();
int t = reader.nextInt();
while (t-- > 0) {
int n=reader.nextInt();
int arr[]=new int[n];
for (int i = 0; i < n; i++) {
arr[i]=reader.nextInt();
}
boolean flag=true;
for(int i=0;i<n;i++)
{
if(!set.contains((long)arr[i]))
{
flag=false;
break;
}
}
if (flag)
{
System.out.println("No");
}
else
{
System.out.println("Yes");
}
}
}
static void SieveOfEratosthenes(int n, boolean prime[],
boolean primesquare[], int a[])
{
// Create a boolean array "prime[0..n]" and
// initialize all entries it as true. A value
// in prime[i] will finally be false if i is
// Not a prime, else true.
for (int i = 2; i <= n; i++)
prime[i] = true;
/* Create a boolean array "primesquare[0..n*n+1]"
and initialize all entries it as false.
A value in squareprime[i] will finally
be true if i is square of prime,
else false.*/
for (int i = 0; i < ((n * n) + 1); i++)
primesquare[i] = false;
// 1 is not a prime number
prime[1] = false;
for (int p = 2; p * p <= n; p++) {
// If prime[p] is not changed,
// then it is a prime
if (prime[p] == true) {
// Update all multiples of p
for (int i = p * 2; i <= n; i += p)
prime[i] = false;
}
}
int j = 0;
for (int p = 2; p <= n; p++) {
if (prime[p]) {
// Storing primes in an array
a[j] = p;
// Update value in
// primesquare[p*p],
// if p is prime.
primesquare[p * p] = true;
j++;
}
}
}
// Function to count divisors
static int countDivisors(int n)
{
// If number is 1, then it will
// have only 1 as a factor. So,
// total factors will be 1.
if (n == 1)
return 1;
boolean prime[] = new boolean[n + 1];
boolean primesquare[] = new boolean[(n * n) + 1];
// for storing primes upto n
int a[] = new int[n];
// Calling SieveOfEratosthenes to
// store prime factors of n and to
// store square of prime factors of n
SieveOfEratosthenes(n, prime, primesquare, a);
// ans will contain total number
// of distinct divisors
int ans = 1;
// Loop for counting factors of n
for (int i = 0;; i++) {
// a[i] is not less than cube root n
if (a[i] * a[i] * a[i] > n)
break;
// Calculating power of a[i] in n.
// cnt is power of prime a[i] in n.
int cnt = 1;
// if a[i] is a factor of n
while (n % a[i] == 0) {
n = n / a[i];
// incrementing power
cnt = cnt + 1;
}
// Calculating the number of divisors
// If n = a^p * b^q then total
// divisors of n are (p+1)*(q+1)
ans = ans * cnt;
}
// if a[i] is greater than cube root
// of n
// First case
if (prime[n])
ans = ans * 2;
// Second case
else if (primesquare[n])
ans = ans * 3;
// Third case
else if (n != 1)
ans = ans * 4;
return ans; // Total divisors
}
public static long[] inarr(long n) throws IOException {
Reader reader = new Reader();
long arr[]=new long[(int) n];
for (long i = 0; i < n; i++) {
arr[(int) i]=reader.nextLong();
}
return arr;
}
public static boolean checkPerfectSquare(int number)
{
int x=number % 10;
if (x==2 || x==3 || x==7 || x==8)
{
return false;
}
for (int i=0; i<=number/2 + 1; i++)
{
if (i*i==number)
{
return true;
}
}
return false;
}
// check number is prime or not
public static boolean isPrime(int n) {
return BigInteger.valueOf(n).isProbablePrime(1);
}
// return the gcd of two numbers
public static long gcd(long a, long b)
{
BigInteger b1 = BigInteger.valueOf(a);
BigInteger b2 = BigInteger.valueOf(b);
BigInteger gcd = b1.gcd(b2);
return gcd.longValue();
}
// number of digits in the given number
public static long numberOfDigits(long n)
{
long ans= (long) (Math.floor((Math.log10(n)))+1);
return ans;
}
// return most significant bit in the number
public static long mostSignificantNumber(long n)
{
double k=Math.log10(n);
k=k-Math.floor(k);
int ans=(int)Math.pow(10,k);
return ans;
}
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')
break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
if (din == null)
return;
din.close();
}
}
} | Java | ["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 | 6160d711e27dfabe3429f079a3411efe | train_110.jsonl | 1618839300 | Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements. | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.StringTokenizer;
public class Hello {
static long mod=(long) (Math.pow(10, 9)+7);
public static void main(String[] args) {
FastScanner sc=new FastScanner();
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int[] arr=sc.readArray(n);
Arrays.sort(arr);
int cnt=0;
for (int i = 0; i < arr.length; i++) {
if(Math.sqrt(arr[i])-Math.floor(Math.sqrt(arr[i]))!=0) cnt++;
}
if(cnt>0) System.out.println("YES");
else System.out.println("NO");
}
}
public static void permute(String suffix,String pref) {
if(suffix.length()==0) {
System.out.println(pref);
return;
}
for(int i=0;i<suffix.length();i++) {
permute(suffix.substring(0,i)+suffix.substring(i+1),pref+suffix.charAt(i));
}
}
public static int gcd(int a,int b) {
if(a==0) return b;
return gcd(b%a,a);
}
static int pow(int a,int b) {
int res=1;
while(b>0) {
if((b&1)==1) {
res*=a;
}
a*=a;
b>>=1;
}
return res;
}
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 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 | dd14ae6bd3e0aaab6d39f00e9dad2125 | 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 static java.lang.Math.*;
import static java.lang.System.out;
import java.util.*;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.math.BigInteger;
public class A {
/* 10^(7) = 1s.
* ceilVal = (a+b-1) / b */
static final int mod = 1000000007;
static final long temp = 998244353;
static final long MOD = 1000000007;
static final long M = (long)1e9+7;
static class Pair implements Comparable<Pair>
{
int first, second;
public Pair(int first, int second)
{
this.first = first;
this.second = second;
}
public int compareTo(Pair ob)
{
return (int)(ob.second - second);
}
}
static class Tuple implements Comparable<Tuple>
{
int first, second,third;
public Tuple(int first, int second, int third)
{
this.first = first;
this.second = second;
this.third = third;
}
public int compareTo(Tuple o)
{
return (int)(o.third - this.third);
}
}
public static class DSU
{
int[] parent;
int[] rank; //Size of the trees is used as the rank
public DSU(int n)
{
parent = new int[n];
rank = new int[n];
Arrays.fill(parent, -1);
Arrays.fill(rank, 1);
}
public int find(int i) //finding through path compression
{
return parent[i] < 0 ? i : (parent[i] = find(parent[i]));
}
public boolean union(int a, int b) //Union Find by Rank
{
a = find(a);
b = find(b);
if(a == b) return false; //if they are already connected we exit by returning false.
// if a's parent is less than b's parent
if(rank[a] < rank[b])
{
//then move a under b
parent[a] = b;
}
//else if rank of j's parent is less than i's parent
else if(rank[a] > rank[b])
{
//then move b under a
parent[b] = a;
}
//if both have the same rank.
else
{
//move a under b (it doesnt matter if its the other way around.
parent[b] = a;
rank[a] = 1 + rank[a];
}
return true;
}
}
static class Reader {
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) throws IOException {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long[] longReadArray(int n) throws IOException {
long[] a=new long[n];
for (int i=0; i<n; i++) a[i]=nextLong();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
public static boolean isPrime(long n)
{
if(n == 1)
{
return false;
}
for(int i = 2;i*i<=n;i++)
{
if(n%i == 0)
{
return false;
}
}
return true;
}
public static List<Long> SieveList(int n)
{
boolean prime[] = new boolean[(int)(n+1)];
Arrays.fill(prime, true);
List<Long> l = new ArrayList<>();
for (long p=2; p*p<=n; p++)
{
if (prime[(int)(p)] == true)
{
for(long i=p*p; i<=n; i += p)
{
prime[(int)(p)] = false;
}
}
}
for (long p=2; p<=n; p++)
{
if (prime[(int)(p)] == true)
{
l.add(p);
}
}
return l;
}
public static int gcd(int a, int b)
{
if(b == 0)
return a;
else
return gcd(b,a%b);
}
public static long lcm(long a, long b)
{
return (a / LongGCD(a, b)) * b;
}
public static long LongGCD(long a, long b)
{
if(b == 0)
return a;
else
return LongGCD(b,a%b);
}
public static long LongLCM(long a, long b)
{
return (a / LongGCD(a, b)) * b;
}
//Count the number of coprime's upto N
public static long phi(long n) //euler totient/phi function
{
long ans = n;
// for(long i = 2;i*i<=n;i++)
// {
// if(n%i == 0)
// {
// while(n%i == 0) n/=i;
// ans -= (ans/i);
// }
// }
//
// if(n > 1)
// {
// ans -= (ans/n);
// }
for(long i = 2;i<=n;i++)
{
if(isPrime(i))
{
ans -= (ans/i);
}
}
return ans;
}
public static long fastPow(long x, long n)
{
if(n == 0)
return 1;
else if(n%2 == 0)
return fastPow(x*x,n/2);
else
return x*fastPow(x*x,(n-1)/2);
}
public static long modPow(long x, long y, long p)
{
long res = 1;
x = x % p;
while (y > 0) {
if (y % 2 == 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
static long modInverse(long n, long p)
{
return modPow(n, p - 2, p);
}
// Returns nCr % p using Fermat's little theorem.
public static long nCrModP(long n, long r,long p)
{
if (n<r)
return 0;
if (r == 0)
return 1;
long[] fac = new long[(int)(n) + 1];
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[(int)(n)] * modInverse(fac[(int)(r)], p)
% p * modInverse(fac[(int)(n - r)], p)
% p)
% p;
}
public static long fact(long n)
{
long[] fac = new long[(int)(n) + 1];
fac[0] = 1;
for (long i = 1; i <= n; i++)
fac[(int)(i)] = fac[(int)(i - 1)] * i;
return fac[(int)(n)];
}
public static long nCr(long n, long k)
{
long ans = 1;
for(long i = 0;i<k;i++)
{
ans *= (n-i);
ans /= (i+1);
}
return ans;
}
public static boolean isSq(long x)
{
long s = (long)Math.round(Math.sqrt(x));
return s*s==x;
}
public static long log2(long n)
{
long ans = (long)(log(n)/log(2));
return ans;
}
public static boolean isPow2(long n)
{
return (n != 0 && ((n & (n-1))) == 0);
}
/*
*
* >= <=
0 1 2 3 4 5 6 7
5 5 5 6 6 6 7 7
lower_bound for 6 at index 3 (>=)
upper_bound for 6 at index 6(To get six reduce by one) (<=)
*
*/
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;
}
//Modular Operations for Addition and Multiplication.
public static long perfomMod(long x)
{
return ((x%M + M)%M);
}
public static long addMod(long a, long b)
{
return perfomMod(perfomMod(a)+perfomMod(b));
}
public static long subMod(long a, long b)
{
return perfomMod(perfomMod(a)-perfomMod(b));
}
public static long mulMod(long a, long b)
{
return perfomMod(perfomMod(a)*perfomMod(b));
}
public static void Sort(int[] a)
{
List<Integer> l = new ArrayList<>();
for (int i : a) l.add(i);
Collections.sort(l);
// Collections.reverse(l); //Use to Sort decreasingly
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
public static void ssort(char[] a)
{
List<Character> l = new ArrayList<>();
for (char i : a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
public static void main(String[] args) throws Exception
{
Reader sc = new Reader();
PrintWriter fout = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-- > 0)
{
int n = sc.nextInt();
int[] a = sc.readArray(n);
boolean flag = false;
for(int i = 0;i<n;i++)
{
if(!isSq(a[i]))
{
flag = true;
break;
}
}
fout.println((flag == true) ? "YES" : "NO");
}
fout.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 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 | 8bd28b445321a03fbe824435a8802c1f | 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 static java.lang.Math.*;
import static java.lang.System.out;
import java.util.*;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.math.BigInteger;
public class A {
/* 10^(7) = 1s.
* ceilVal = (a+b-1) / b */
static final int mod = 1000000007;
static final long temp = 998244353;
static final long MOD = 1000000007;
static final long M = (long)1e9+7;
static class Pair implements Comparable<Pair>
{
long first, second;
public Pair(long first, long second)
{
this.first = first;
this.second = second;
}
public int compareTo(Pair ob)
{
return (int)(ob.second - second);
}
}
static class Tuple implements Comparable<Tuple>{
long first, second,third;
public Tuple(long first, long second, long third)
{
this.first = first;
this.second = second;
this.third = third;
}
public int compareTo(Tuple o)
{
return (int)(o.third - this.third);
}
}
public static class DSU
{
int[] parent;
int[] rank; //Size of the trees is used as the rank
public DSU(int n)
{
parent = new int[n];
rank = new int[n];
Arrays.fill(parent, -1);
Arrays.fill(rank, 1);
}
public int find(int i) //finding through path compression
{
return parent[i] < 0 ? i : (parent[i] = find(parent[i]));
}
public boolean union(int a, int b) //Union Find by Rank
{
a = find(a);
b = find(b);
if(a == b) return false; //if they are already connected we exit by returning false.
// if a's parent is less than b's parent
if(rank[a] < rank[b])
{
//then move a under b
parent[a] = b;
}
//else if rank of j's parent is less than i's parent
else if(rank[a] > rank[b])
{
//then move b under a
parent[b] = a;
}
//if both have the same rank.
else
{
//move a under b (it doesnt matter if its the other way around.
parent[b] = a;
rank[a] = 1 + rank[a];
}
return true;
}
}
static class Reader {
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) throws IOException {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long[] longReadArray(int n) throws IOException {
long[] a=new long[n];
for (int i=0; i<n; i++) a[i]=nextLong();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
public static boolean isPrime(long n)
{
if(n == 1)
{
return false;
}
for(int i = 2;i*i<=n;i++)
{
if(n%i == 0)
{
return false;
}
}
return true;
}
public static List<Integer> SieveList(int n)
{
boolean prime[] = new boolean[n+1];
Arrays.fill(prime, true);
ArrayList<Integer> l = new ArrayList<>();
for (int p=2; p*p<=n; p++)
{
if (prime[p] == true)
{
for(int i=p*p; i<=n; i += p)
{
prime[i] = false;
}
}
}
for (int p=2; p<=n; p++)
{
if (prime[p] == true)
{
l.add(p);
}
}
return l;
}
public static int gcd(int a, int b)
{
if(b == 0)
return a;
else
return gcd(b,a%b);
}
public static int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
public static long LongGCD(long a, long b)
{
if(b == 0)
return a;
else
return LongGCD(b,a%b);
}
public static long LongLCM(long a, long b)
{
return (a / LongGCD(a, b)) * b;
}
//Count the number of coprime's upto N
public static long phi(long n) //euler totient/phi function
{
long ans = n;
// for(long i = 2;i*i<=n;i++)
// {
// if(n%i == 0)
// {
// while(n%i == 0) n/=i;
// ans -= (ans/i);
// }
// }
//
// if(n > 1)
// {
// ans -= (ans/n);
// }
for(long i = 2;i<=n;i++)
{
if(isPrime(i))
{
ans -= (ans/i);
}
}
return ans;
}
public static long fastPow(long x, long n)
{
if(n == 0)
return 1;
else if(n%2 == 0)
return fastPow(x*x,n/2);
else
return x*fastPow(x*x,(n-1)/2);
}
public static long modPow(long x, long y, long p)
{
long res = 1;
x = x % p;
while (y > 0) {
if (y % 2 == 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
static long modInverse(long n, long p)
{
return modPow(n, p - 2, p);
}
// Returns nCr % p using Fermat's little theorem.
public static long nCrModP(long n, long r,long p)
{
if (n<r)
return 0;
if (r == 0)
return 1;
long[] fac = new long[(int)(n) + 1];
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[(int)(n)] * modInverse(fac[(int)(r)], p)
% p * modInverse(fac[(int)(n - r)], p)
% p)
% p;
}
public static long fact(long n) {
long[] fac = new long[(int)(n) + 1];
fac[0] = 1;
for (long i = 1; i <= n; i++)
fac[(int)(i)] = fac[(int)(i - 1)] * i;
return fac[(int)(n)];
}
public static long nCr(long n, long k)
{
long ans = 1;
for(long i = 0;i<k;i++)
{
ans *= (n-i);
ans /= (i+1);
}
return ans;
}
public static void Sort(int[] a)
{
List<Integer> l = new ArrayList<>();
for (int i : a) l.add(i);
Collections.sort(l);
Collections.reverse(l); //Use to Sort decreasingly
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
public static void ssort(char[] a)
{
List<Character> l = new ArrayList<>();
for (char i : a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
//Modular Operations for Addition and Multiplication.
public static long perfomMod(long x)
{
return ((x%M + M)%M);
}
public static long addMod(long a, long b)
{
return perfomMod(perfomMod(a)+perfomMod(b));
}
public static long subMod(long a, long b)
{
return perfomMod(perfomMod(a)-perfomMod(b));
}
public static long mulMod(long a, long b)
{
return perfomMod(perfomMod(a)*perfomMod(b));
}
public static boolean isPow(int x)
{
long s = (long)Math.round(Math.sqrt(x));
return s*s==x;
}
/*
*
* >= <=
0 1 2 3 4 5 6 7
5 5 5 6 6 6 7 7
lower_bound for 6 at index 3 (>=)
upper_bound for 6 at index 6(To get six reduce by one) (<=)
*/
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;
}
public static void main(String[] args) throws Exception
{
Reader sc = new Reader();
PrintWriter fout = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-- > 0)
{
int n = sc.nextInt();
int[] a = sc.readArray(n);
boolean ok = false;
for(int i = 0;i<n;i++)
{
if(isPow(a[i]) == false)
{
ok = true;
break;
}
}
fout.println(((ok == true) ? "YES" : " NO"));
}
fout.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 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 | a4bb8214463eab3ceaf6ab5343a43f43 | 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 static java.lang.Math.*;
import static java.lang.System.out;
import java.util.*;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.math.BigInteger;
public class A {
/* 10^(7) = 1s.
* ceilVal = (a+b-1) / b */
static final int mod = 1000000007;
static final long temp = 998244353;
static final long MOD = 1000000007;
static final long M = (long)1e9+7;
static class Pair implements Comparable<Pair>
{
long first, second;
public Pair(long first, long second)
{
this.first = first;
this.second = second;
}
public int compareTo(Pair ob)
{
return (int)(ob.second - second);
}
}
static class Tuple implements Comparable<Tuple>{
long first, second,third;
public Tuple(long first, long second, long third)
{
this.first = first;
this.second = second;
this.third = third;
}
public int compareTo(Tuple o)
{
return (int)(o.third - this.third);
}
}
public static class DSU
{
int[] parent;
int[] rank; //Size of the trees is used as the rank
public DSU(int n)
{
parent = new int[n];
rank = new int[n];
Arrays.fill(parent, -1);
Arrays.fill(rank, 1);
}
public int find(int i) //finding through path compression
{
return parent[i] < 0 ? i : (parent[i] = find(parent[i]));
}
public boolean union(int a, int b) //Union Find by Rank
{
a = find(a);
b = find(b);
if(a == b) return false; //if they are already connected we exit by returning false.
// if a's parent is less than b's parent
if(rank[a] < rank[b])
{
//then move a under b
parent[a] = b;
}
//else if rank of j's parent is less than i's parent
else if(rank[a] > rank[b])
{
//then move b under a
parent[b] = a;
}
//if both have the same rank.
else
{
//move a under b (it doesnt matter if its the other way around.
parent[b] = a;
rank[a] = 1 + rank[a];
}
return true;
}
}
static class Reader {
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) throws IOException {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long[] longReadArray(int n) throws IOException {
long[] a=new long[n];
for (int i=0; i<n; i++) a[i]=nextLong();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
public static boolean isPrime(long n)
{
if(n == 1)
{
return false;
}
for(int i = 2;i*i<=n;i++)
{
if(n%i == 0)
{
return false;
}
}
return true;
}
public static List<Integer> SieveList(int n)
{
boolean prime[] = new boolean[n+1];
Arrays.fill(prime, true);
ArrayList<Integer> l = new ArrayList<>();
for (int p=2; p*p<=n; p++)
{
if (prime[p] == true)
{
for(int i=p*p; i<=n; i += p)
{
prime[i] = false;
}
}
}
for (int p=2; p<=n; p++)
{
if (prime[p] == true)
{
l.add(p);
}
}
return l;
}
public static int gcd(int a, int b)
{
if(b == 0)
return a;
else
return gcd(b,a%b);
}
public static int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
public static long LongGCD(long a, long b)
{
if(b == 0)
return a;
else
return LongGCD(b,a%b);
}
public static long LongLCM(long a, long b)
{
return (a / LongGCD(a, b)) * b;
}
//Count the number of coprime's upto N
public static long phi(long n) //euler totient/phi function
{
long ans = n;
// for(long i = 2;i*i<=n;i++)
// {
// if(n%i == 0)
// {
// while(n%i == 0) n/=i;
// ans -= (ans/i);
// }
// }
//
// if(n > 1)
// {
// ans -= (ans/n);
// }
for(long i = 2;i<=n;i++)
{
if(isPrime(i))
{
ans -= (ans/i);
}
}
return ans;
}
public static long fastPow(long x, long n)
{
if(n == 0)
return 1;
else if(n%2 == 0)
return fastPow(x*x,n/2);
else
return x*fastPow(x*x,(n-1)/2);
}
public static long modPow(long x, long y, long p)
{
long res = 1;
x = x % p;
while (y > 0) {
if (y % 2 == 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
static long modInverse(long n, long p)
{
return modPow(n, p - 2, p);
}
// Returns nCr % p using Fermat's little theorem.
public static long nCrModP(long n, long r,long p)
{
if (n<r)
return 0;
if (r == 0)
return 1;
long[] fac = new long[(int)(n) + 1];
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[(int)(n)] * modInverse(fac[(int)(r)], p)
% p * modInverse(fac[(int)(n - r)], p)
% p)
% p;
}
public static long fact(long n) {
long[] fac = new long[(int)(n) + 1];
fac[0] = 1;
for (long i = 1; i <= n; i++)
fac[(int)(i)] = fac[(int)(i - 1)] * i;
return fac[(int)(n)];
}
public static long nCr(long n, long k)
{
long ans = 1;
for(long i = 0;i<k;i++)
{
ans *= (n-i);
ans /= (i+1);
}
return ans;
}
public static void Sort(int[] a)
{
List<Integer> l = new ArrayList<>();
for (int i : a) l.add(i);
Collections.sort(l);
Collections.reverse(l); //Use to Sort decreasingly
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
public static void ssort(char[] a)
{
List<Character> l = new ArrayList<>();
for (char i : a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
//Modular Operations for Addition and Multiplication.
public static long perfomMod(long x)
{
return ((x%M + M)%M);
}
public static long addMod(long a, long b)
{
return perfomMod(perfomMod(a)+perfomMod(b));
}
public static long subMod(long a, long b)
{
return perfomMod(perfomMod(a)-perfomMod(b));
}
public static long mulMod(long a, long b)
{
return perfomMod(perfomMod(a)*perfomMod(b));
}
/*
*
* >= <=
0 1 2 3 4 5 6 7
5 5 5 6 6 6 7 7
lower_bound for 6 at index 3 (>=)
upper_bound for 6 at index 6(To get six reduce by one) (<=)
*/
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;
}
public static boolean isPow(int n)
{
double l = Math.ceil((double)(sqrt(n)));
double r = Math.floor((double)Math.sqrt(n));
return (l == r);
}
public static void main(String[] args) throws Exception
{
Reader sc = new Reader();
PrintWriter fout = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-- > 0)
{
int n = sc.nextInt();
int[] a = sc.readArray(n);
boolean ok = false;
for(int i = 0;i<n;i++)
{
if(!isPow(a[i]))
{
ok = true;
break;
}
}
fout.println((ok == true) ? "YES" : "NO");
}
fout.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 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 | c91818955cdc95e4d513c2f1a88e2045 | 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.ArrayList;
import java.util.Scanner;
public class solution_codeforces {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int T = scan.nextInt();
while(T-- > 0){
int n = scan.nextInt();
int[] arr = new int[n];
for(int i = 0 ; i < n; i++){
arr[i] = scan.nextInt();
}
boolean ans = false;
for(int i = 0; i < arr.length; i++){
if(checkPerfectSquare((long)arr[i]) == false){
ans = true;
break;
}
}
if(ans){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
}
public static boolean checkPerfectSquare(long number)
{
double sqrt=Math.sqrt((double)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 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 | bc382bf2f8cce3786f1fcde7d73bf8df | 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;
}
}
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 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 | f1479da867f6bc2893a980a0cef9c143 | 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.reflect.Array;
import java.util.*;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
// write your code here
PrintWriter out = new PrintWriter(System.out);
FastReader scan = new FastReader();
Task solver = new Task();
solver.solve(1,scan,out);
out.close();
}
static class Task{
public void solve(int testNumber, FastReader scan, PrintWriter out) {
int t = scan.nextInt();
for(int i=0; i<t;i++){
boolean isOk=false;
int n = scan.nextInt();
ArrayList<Integer> list = new ArrayList<>();
for(int j=0; j<n;j++){
list.add(scan.nextInt());
}
for(int j=0;j<n;j++){
int sqrt = (int)Math.sqrt(list.get(j));
if(sqrt*sqrt!=list.get(j)){
isOk=true;
}
}
if(isOk){
out.println("YES");
}else{
out.println("NO");
}
}
}
public static boolean isValid(int x, int y, int n){
if(x<0 || y<0 || x>=n || y>=n){
return false;
}
return true;
}
public static int factorial(int n){
if(n<=1){
return 1;
}else{
return n*factorial(n-1);
}
}
public static int DBD(int a, int b){
int answer=1;
for(int i=1; i<=Math.min(a,b);i++){
if(a%i==0 && b%i==0){
answer=i;
}
}
return answer;
}
public static boolean isPrime(int n){
if(n<2){
return false;
}
for(int i=2; i<Math.sqrt(n)+1 ;i++){
if(n%i==0){
return false;
}
}
return true;
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws FileNotFoundException {
br = new BufferedReader(new FileReader(new File(s)));
}
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 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 | 5127700af6342b102545e3e44adca90e | 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 A {
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 ans = true;
for (int j = 0; j < n; j++) {
int a = sc.nextInt();
int srt = (int) Math.sqrt(a);
if (srt * srt != a) {
ans = false;
}
}
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 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 | 142c029f3221b803b0ddbd04b8b6d8e0 | 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.lang.*;
public class Main {
//input
static out op = new out();
static inp ip = new inp();
static FastReader sc = new FastReader();
static BufferedWriter output = new BufferedWriter(
new OutputStreamWriter(System.out));
//HashMap<Integer,Integer> map = new HashMap<>();
// for(int i=0;i<n;i++){
// }
static void sol(boolean sq[]) throws Exception{
int n = ip.in();
int[] arr = ip.arrin(n);
for(int e:arr)
{
if(!sq[e]){
op.yes();
return;
}
}
op.no();
}
static int gcd(int a,int b){
if(b==0)
return a;
return gcd(b,a%b);
}
public static void main(String[] args) throws Exception {
int t = ip.in();
boolean[] pow = new boolean[10001];
for(int i=1;i*i<=10000;i++)
pow[i*i] = true;
while(t-- > 0){
sol(pow);
}
op.output.flush();
}
static class Node /*implements Comparable<Node>*/{
int data[] = new int[26];
int val;
Node left,right;
Node(){
left = null;
right = null;
}
Node(char ch){
left = null;
right = null;
}
// @Override
// // public int compareTo(Node o) {
// // if(this.data == o.data)
// // return this.ind - o.ind;
// // // TODO Auto-generated method stub
// // return o.data - this.data;
// // }
}
}
class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
class inp{
FastReader sc = new FastReader();
int in(){
int a = sc.nextInt();
return a;
}
long lin(){
long a = sc.nextLong();
return a;
}
char cin(){
char c = sc.next().charAt(0);
return c;
}
char[] cain(){
char[] a = sc.nextLine().toCharArray();
return a;
}
int[] arrin(int n){
int [] arr = new int[n];
for(int i=0;i<n;i++)
arr[i] = in();
return arr;
}
int[] mm_arr(int[] arr){
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
for(int i=0;i<arr.length;i++){
max = Math.max(max,arr[i]);
min = Math.min(min,arr[i]);
}
int ans[] = {max,min};
return ans;
}
int[] srt(int[] arr){
Arrays.sort(arr);
return arr;
}
long pow(long a,long b){
if(b == 0)return 1;
long res = pow(a,b/2);
//System.out.println(res + " " + b + " " + (b&1));
if((b&1) == 0)return res*res;
return a*res*res;
}
boolean[] prime(){
boolean prime[] = new boolean[100000001];
Arrays.fill(prime,true);
for (int p = 2; p * p <= 10000000; p++)
{
// If prime[p] is not changed,
// then it is a prime
if (prime[p] == true)
{
// Update all multiples
// of p greater than or
// equal to the square of it
// numbers which are multiple
// of p and are less than p^2
// are already been marked.
for (int i = p * p; i <= 10000000; i += p)
prime[i] = false;
}
}
return prime;
}
}
class out{
BufferedWriter output = new BufferedWriter(
new OutputStreamWriter(System.out));
void sb(String s) throws IOException {
output.write(s);
}
void sbln(Object s) throws IOException {
output.write(s+"\n");
}
void yes() throws IOException{
output.write("YES\n");
}
void no() throws IOException{
output.write("NO\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 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 | f602b0ebfe7d2a9af6eb7cd9c377075f | 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.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.lang.Math;
public class Account {
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 flag= false ;
for(int i=0 ;i<n ;i++ ) {
arr[i]= sc.nextInt() ;
if(isPerfectSquare(arr[i]) == false && flag == false) {
flag= true ;
// break ;
}
}
if(flag == true) {
System.out.println("YES");
}else {
System.out.println("NO");
}
}
}
static boolean isPerfectSquare(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 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 | 4266568b137a4214f71c2e051627e0af | 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.math.*;
public class B
{
public static void main(String[] args) throws IOException
{
//StringBuffer sb=new StringBuffer("");
Scanner sc=new Scanner(System.in);
int ttt=sc.nextInt();
while(ttt-->0)
{int ans=0;
int a=sc.nextInt();int n[]=new int[a];long p=1;
for(int i=0;i<a;i++)
{
n[i]=sc.nextInt();
p=n[i];
if(Math.floor(Math.sqrt(p))!=Math.ceil(Math.sqrt(p)))
ans=1;
}
if(ans==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 | |
PASSED | c0ed5de55305b6b3c8cc741404f3ddff | 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 Problem{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for (int i =0 ; i< t; i++){
int n = input.nextInt();
boolean a = false;
for (int j = 0; j<n; j++){
int x = input.nextInt();
if (Math.sqrt(x) != (int) Math.sqrt(x)){
a = true;
}
}
if (a){
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 | |
PASSED | 6e17d8c1ecf8cc3c6dc03f28c7559bae | 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 a
{
static class FastScanner {
InputStreamReader is;
BufferedReader br;
StringTokenizer st;
public FastScanner() {
is = new InputStreamReader(System.in);
br = new BufferedReader(is);
}
String next() throws Exception {
while (st == null || !st.hasMoreElements())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
int nextInt() throws Exception {
return Integer.parseInt(next());
}
long nextLong() throws Exception {
return Long.parseLong(next());
}
int[] readArray(int num) throws Exception {
int arr[]=new int[num];
for(int i=0;i<num;i++)
arr[i]=nextInt();
return arr;
}
String nextLine() throws Exception {
return br.readLine();
}
}
public static boolean power_of_two(int a)
{
if((a&(a-1))==0)
{
return true;
}
return false;
}
public static void main(String args[]) throws java.lang.Exception
{
FastScanner sc=new FastScanner();
int t=sc.nextInt();
while(t--> 0)
{
int n=sc.nextInt();
int count=0;
for(int i=0;i<n;i++)
{
boolean ans=ck(sc.nextInt());
if(ans)
count++;
}
if(count==n)
{
System.out.println("NO");
continue;
}
System.out.println("YES");
}
}
public static boolean ck(int n)
{
if (Math.ceil((double)Math.sqrt(n)) == Math.floor((double)Math.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 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 | 3233ad9e3a48515470dd51ff0ccb2252 | 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 a
{
static class FastScanner {
InputStreamReader is;
BufferedReader br;
StringTokenizer st;
public FastScanner() {
is = new InputStreamReader(System.in);
br = new BufferedReader(is);
}
String next() throws Exception {
while (st == null || !st.hasMoreElements())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
int nextInt() throws Exception {
return Integer.parseInt(next());
}
long nextLong() throws Exception {
return Long.parseLong(next());
}
int[] readArray(int num) throws Exception {
int arr[]=new int[num];
for(int i=0;i<num;i++)
arr[i]=nextInt();
return arr;
}
String nextLine() throws Exception {
return br.readLine();
}
}
public static boolean power_of_two(int a)
{
if((a&(a-1))==0)
{
return true;
}
return false;
}
public static void main(String args[]) throws java.lang.Exception
{
FastScanner sc=new FastScanner();
int t=sc.nextInt();
while(t--> 0)
{
int n=sc.nextInt();
int count=0;
for(int i=0;i<n;i++)
{
boolean ans=ck(sc.nextInt());
if(ans)
count++;
}
if(count==n)
{
System.out.println("NO");
continue;
}
System.out.println("YES");
}
}
public static boolean ck(int n)
{
if (Math.ceil((double)Math.sqrt(n)) == Math.floor((double)Math.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 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 | 2e950bf0aa858b09cd8c94a319b109ad | 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.Math;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int test = Integer.parseInt(br.readLine());
for (int t = 0; t < test; t++) {
int n = Integer.parseInt(br.readLine());
List<Integer> a = new ArrayList<Integer>(n);
StringTokenizer st = new StringTokenizer(br.readLine());
while (st.hasMoreTokens()) a.add(Integer.parseInt(st.nextToken()));
loop: for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
int sq = a.get(i)*a.get(j), sqrt = (int) Math.sqrt(sq);
if (Math.pow(sqrt, 2) != sq) { //If not perfect square
pw.println("YES");
break loop;
}
}
if (Math.pow((int) Math.sqrt(a.get(i)), 2) != a.get(i)) {
pw.println("YES");
break;
}
if (i == n-1) {
pw.println("NO");
}
}
}
pw.close();
return;
}
} | 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 | ee66a83690df701c48f24a19135a228a | 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;
public class cp {
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 int GCD(int a,int b){
if(b==0)return a;
return GCD(b%a,a);
}
public static void main(String[] args)
{
FastReader s = new FastReader();
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();
}
boolean flag=false;
for(int i:arr){
//double temp=Math.sqrt(i);
if(!isPerfectSquare(i))flag=true;
}
System.out.println(flag?"YES":"NO");
}
}
static boolean isPerfectSquare(int n)
{
for (int i = 1; i * i <= n; i++) {
// If (i * i = n)
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 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 | ecce48946c965e42a0f04f7ffc372464 | 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 Solution
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int k=1;k<=t;k++)
{
int n = sc.nextInt();
int[] a = new int[n];
for(int i=0;i<n;i++) {a[i]=sc.nextInt();}
int ctr=0;
for(int i=0;i<n;i++)
{
//double sr = Math.sqrt(a[i]);
if(Math.ceil((double)Math.sqrt(a[i])) != Math.floor((double)Math.sqrt(a[i]))) {
ctr=1;break;}
}
if(ctr==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 | |
PASSED | 58d34574116f0adf56f020efdde52178 | 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{
static boolean perfs(int x){
int p=(int)Math.sqrt(x);
return p*p==x;
}
static void solve(int a[],int n){
for(int i=0;i<n;i++)
{
if(!perfs(a[i]))
{System.out.println("YES");
return ;
}}
System.out.println("NO");
}
public static void main(String[] args){
Scanner in=new Scanner(System.in);
int t=in.nextInt();
while(t-->0){
int sq=0;
int n=in.nextInt();
int[] a=new int[n];
for(int i=0;i<n;i++)
a[i]=in.nextInt();
solve(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 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 | 440cefe9769b7154858cd0b41e7b3b7a | 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{
static boolean isPerfectSquare(double x)
{
if (x >= 0) {
double sr = Math.sqrt(x);
sr=(int)Math.ceil(sr);
return ((sr * sr) == (int)x);
}
return false;
}
public static void main(String args[]){
Scanner sc =new Scanner(System.in);
int t=sc.nextInt();
int i;
while(t-->0){
int n=sc.nextInt();
double arr[]=new double[n];
int c=0;
for(i=0;i<n;i++){
arr[i]=sc.nextDouble();
if (isPerfectSquare(arr[i])==true){
c++;
}
}
if(c==n){
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 | a410dc7e64c1d44b5d71b121177a86d0 | 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 | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
long t= sc.nextLong();
while(t-- > 0) {
long n = sc.nextLong();
long[] arr = new long[(int)n];
for(int i=0;i<n;i++) {
arr[i] = sc.nextLong();
}
boolean check = false;
for(int i=0;i<n;i++) {
if(!isPerSqar(arr[i])) {
System.out.println("YES");
check = true;
break;
}
}
if(!check)
System.out.println("NO");
}
}
public static boolean isPerSqar(long n) {
long sr = (long)Math.sqrt(n);
return ((sr * sr) == 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 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 | 37f0922b3c961be891027fc5460cb40b | 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 CP
{
static class FastIO {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
public String next() {
while (!st.hasMoreElements())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
int nextInt () {
return Integer.parseInt(next());
}
}
public static void main(String[] args) throws Exception
{
FastIO in = new FastIO();
int t= in.nextInt();
while(t-- > 0)
{
int n = in.nextInt();
int arr[] = in.readArray(n);
boolean ok = false;
for (int i = 0; i < arr.length; i++) {
int x = (int) Math.floor(Math.sqrt(arr[i]));
if(x*x != arr[i])
{
ok = true;
break;
}
}
if(ok)
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 | |
PASSED | 3ef5d20f797ee821e2b6e665bfd08e87 | 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.BigInteger;
import java.util.*;
public class Stack1 {
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')
break;
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();
}
}
static Reader sc = new Reader();
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException {
/*
* For integer input: int n=inputInt();
* For long input: long n=inputLong();
* For double input: double n=inputDouble();
* For String input: String s=inputString();
* Logic goes here
* For printing without space: print(a+""); where a is a variable of any datatype
* For printing with space: printSp(a+""); where a is a variable of any datatype
* For printing with new line: println(a+""); where a is a variable of any datatype
*/
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int n = sc.nextInt();
boolean check = false;
for (int j = 0; j < n; j++) {
int num = sc.nextInt();
double ans = Math.sqrt(num);
double a1 = Math.ceil(ans);
//System.out.println(a1+" "+ans);
if (a1 != ans) {
check = true;
// break;
}
}
if (check) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
bw.flush();
bw.close();
}
public static void dfs1(List<List<Integer>> g, boolean[] visited, Stack<Integer> stack, int num) {
visited[num] = true;
for (Integer integer : g.get(num)) {
if (!visited[integer]) {
dfs1(g, visited, stack, integer);
}
}
stack.push(num);
}
public static void dfs2(List<List<Integer>> g, boolean[] visited, List<Integer> list, int num, int c, int[] raj) {
visited[num] = true;
for (Integer integer : g.get(num)) {
if (!visited[integer]) {
dfs2(g, visited, list, integer, c, raj);
}
}
raj[num] = c;
list.add(num);
}
public static int inputInt() throws IOException {
return sc.nextInt();
}
public static long inputLong() throws IOException {
return sc.nextLong();
}
public static double inputDouble() throws IOException {
return sc.nextDouble();
}
public static String inputString() throws IOException {
return sc.readLine();
}
public static void print(String a) throws IOException {
bw.write(a);
}
public static void printSp(String a) throws IOException {
bw.write(a + " ");
}
public static void println(String a) throws IOException {
bw.write(a + "\n");
}
public static long getAns(int[] ar, int c, long[][] dp, int i, int sign) {
if (i < 0) {
return 1;
}
if (c <= 0) {
return 1;
}
dp[i][c] = Math.max(dp[i][c], Math.max(ar[i] * getAns(ar, c - 1, dp, i - 1, sign), getAns(ar, c, dp, i - 1, 1)));
return dp[i][c];
}
public static long power(long a, long b, long c) {
long ans = 1;
while (b != 0) {
if (b % 2 == 1) {
ans = ans * a;
ans %= c;
}
a = a * a;
a %= c;
b /= 2;
}
return ans;
}
public static long power1(long a, long b, long c) {
long ans = 1;
while (b != 0) {
if (b % 2 == 1) {
ans = multiply(ans, a, c);
}
a = multiply(a, a, c);
b /= 2;
}
return ans;
}
public static long multiply(long a, long b, long c) {
long res = 0;
a %= c;
while (b > 0) {
if (b % 2 == 1) {
res = (res + a) % c;
}
a = (a + a) % c;
b /= 2;
}
return res % c;
}
public static long totient(long n) {
long result = n;
for (long i = 2; i * i <= n; i++) {
if (n % i == 0) {
//sum=sum+2*i;
while (n % i == 0) {
n /= i;
// sum=sum+n;
}
result -= result / i;
}
}
if (n > 1) {
result -= result / n;
}
return result;
}
public static long gcd(long a, long b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
public static boolean[] primes(int n) {
boolean[] p = new boolean[n + 1];
p[0] = false;
p[1] = false;
for (int i = 2; i <= n; i++) {
p[i] = true;
}
for (int i = 2; i * i <= n; i++) {
if (p[i]) {
for (int j = i * i; j <= n; j += i) {
p[j] = false;
}
}
}
return p;
}
} | 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 | 3f0d06854097faed34f0e47b0520d14a | 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.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
public final class CFPS {
static FastReader fr = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
static final int gigamod = 1000000007;
static final int mod = 998244353;
static int t = 1;
static boolean[] isPrime;
static int[] smallestFactorOf;
static final int UP = 0, LEFT = 1, DOWN = 2, RIGHT = 3;
static long cmp;
@SuppressWarnings({"unused"})
public static void main(String[] args) throws Exception {
t = fr.nextInt();
OUTER:
for (int tc = 0; tc < t; tc++) {
int n = fr.nextInt();
int[] arr = fr.nextIntArray(n);
// one non-square element
for (int i = 0; i < n; i++) {
long prod = arr[i];
long sqrt = (long) Math.sqrt(prod);
if (sqrt * sqrt != prod) {
YES();
continue OUTER;
}
}
NO();
}
out.close();
}
static class Pair implements Comparable<Pair> {
int first, second;
int idx;
Pair() { first = second = 0; }
Pair (int ff, int ss) {first = ff; second = ss;}
Pair (int ff, int ss, int ii) { first = ff; second = ss; idx = ii; }
public int compareTo(Pair that) {
cmp = first - that.first;
if (cmp == 0)
cmp = second - that.second;
return (int) cmp;
}
}
// (range add - segment min) segTree
static int nn;
static int[] arr;
static int[] tree;
static int[] lazy;
static void build(int node, int leftt, int rightt) {
if (leftt == rightt) {
tree[node] = arr[leftt];
return;
}
int mid = (leftt + rightt) >> 1;
build(node << 1, leftt, mid);
build(node << 1 | 1, mid + 1, rightt);
tree[node] = Math.min(tree[node << 1], tree[node << 1 | 1]);
}
static void segAdd(int node, int leftt, int rightt, int segL, int segR, int val) {
if (lazy[node] != 0) {
tree[node] += lazy[node];
if (leftt != rightt) {
lazy[node << 1] += lazy[node];
lazy[node << 1 | 1] += lazy[node];
}
lazy[node] = 0;
}
if (segL > rightt || segR < leftt) return;
if (segL <= leftt && rightt <= segR) {
tree[node] += val;
if (leftt != rightt) {
lazy[node << 1] += val;
lazy[node << 1 | 1] += val;
}
lazy[node] = 0;
return;
}
int mid = (leftt + rightt) >> 1;
segAdd(node << 1, leftt, mid, segL, segR, val);
segAdd(node << 1 | 1, mid + 1, rightt, segL, segR, val);
tree[node] = Math.min(tree[node << 1], tree[node << 1 | 1]);
}
static int minQuery(int node, int leftt, int rightt, int segL, int segR) {
if (lazy[node] != 0) {
tree[node] += lazy[node];
if (leftt != rightt) {
lazy[node << 1] += lazy[node];
lazy[node << 1 | 1] += lazy[node];
}
lazy[node] = 0;
}
if (segL > rightt || segR < leftt) return Integer.MAX_VALUE / 10;
if (segL <= leftt && rightt <= segR)
return tree[node];
int mid = (leftt + rightt) >> 1;
return Math.min(minQuery(node << 1, leftt, mid, segL, segR),
minQuery(node << 1 | 1, mid + 1, rightt, segL, segR));
}
static class Segment {
int li, ri, wi, id;
Segment(int ll, int rr, int ww, int ii) {
li = ll;
ri = rr;
wi = ww;
id = ii;
}
}
static void compute_automaton(String s, int[][] aut) {
s += '#';
int n = s.length();
int[] pi = prefix_function(s.toCharArray());
for (int i = 0; i < n; i++) {
for (int c = 0; c < 26; c++) {
int j = i;
while (j > 0 && 'A' + c != s.charAt(j))
j = pi[j-1];
if ('A' + c == s.charAt(j))
j++;
aut[i][c] = j;
}
}
}
static void timeDFS(int current, int from, UGraph ug,
int[] time, int[] tIn, int[] tOut) {
tIn[current] = ++time[0];
for (int adj : ug.adj(current))
if (adj != from)
timeDFS(adj, current, ug, time, tIn, tOut);
tOut[current] = ++time[0];
}
static boolean areCollinear(long x1, long y1, long x2, long y2, long x3, long y3) {
// we will check if c3 lies on line through (c1, c2)
long a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
return a == 0;
}
static int[] treeDiameter(UGraph ug) {
int n = ug.V();
int farthest = -1;
int[] distTo = new int[n];
diamDFS(0, -1, 0, ug, distTo);
int maxDist = -1;
for (int i = 0; i < n; i++)
if (maxDist < distTo[i]) {
maxDist = distTo[i];
farthest = i;
}
distTo = new int[n + 1];
diamDFS(farthest, -1, 0, ug, distTo);
distTo[n] = farthest;
return distTo;
}
static void diamDFS(int current, int from, int dist, UGraph ug, int[] distTo) {
distTo[current] = dist;
for (int adj : ug.adj(current))
if (adj != from)
diamDFS(adj, current, dist + 1, ug, distTo);
}
static class TreeDistFinder {
UGraph ug;
int n;
int[] depthOf;
LCA lca;
TreeDistFinder(UGraph ug) {
this.ug = ug;
n = ug.V();
depthOf = new int[n];
depthCalc(0, -1, ug, 0, depthOf);
lca = new LCA(ug, 0);
}
TreeDistFinder(UGraph ug, int a) {
this.ug = ug;
n = ug.V();
depthOf = new int[n];
depthCalc(a, -1, ug, 0, depthOf);
lca = new LCA(ug, a);
}
private void depthCalc(int current, int from, UGraph ug, int depth, int[] depthOf) {
depthOf[current] = depth;
for (int adj : ug.adj(current))
if (adj != from)
depthCalc(adj, current, ug, depth + 1, depthOf);
}
public int dist(int a, int b) {
int lc = lca.lca(a, b);
return (depthOf[a] - depthOf[lc] + depthOf[b] - depthOf[lc]);
}
}
public static long[][] GCDSparseTable(long[] a)
{
int n = a.length;
int b = 32-Integer.numberOfLeadingZeros(n);
long[][] ret = new long[b][];
for(int i = 0, l = 1;i < b;i++, l*=2) {
if(i == 0) {
ret[i] = a;
} else {
ret[i] = new long[n-l+1];
for(int j = 0;j < n-l+1;j++) {
ret[i][j] = gcd(ret[i-1][j], ret[i-1][j+l/2]);
}
}
}
return ret;
}
public static long sparseRangeGCDQ(long[][] table, int l, int r)
{
// [a,b)
if(l > r)return 1;
// 1:0, 2:1, 3:1, 4:2, 5:2, 6:2, 7:2, 8:3
int t = 31-Integer.numberOfLeadingZeros(r-l);
return gcd(table[t][l], table[t][r-(1<<t)]);
}
static class Trie {
TrieNode root;
Trie(char[][] strings) {
root = new TrieNode('A', false);
construct(root, strings);
}
public Stack<String> set(TrieNode root) {
Stack<String> set = new Stack<>();
StringBuilder sb = new StringBuilder();
for (TrieNode next : root.next)
collect(sb, next, set);
return set;
}
private void collect(StringBuilder sb, TrieNode node, Stack<String> set) {
if (node == null) return;
sb.append(node.character);
if (node.isTerminal)
set.add(sb.toString());
for (TrieNode next : node.next)
collect(sb, next, set);
if (sb.length() > 0)
sb.setLength(sb.length() - 1);
}
private void construct(TrieNode root, char[][] strings) {
// we have to construct the Trie
for (char[] string : strings) {
if (string.length == 0) continue;
root.next[string[0] - 'a'] = put(root.next[string[0] - 'a'], string, 0);
if (root.next[string[0] - 'a'] != null)
root.isLeaf = false;
}
}
private TrieNode put(TrieNode node, char[] string, int idx) {
boolean isTerminal = (idx == string.length - 1);
if (node == null) node = new TrieNode(string[idx], isTerminal);
node.character = string[idx];
node.isTerminal |= isTerminal;
if (!isTerminal) {
node.isLeaf = false;
node.next[string[idx + 1] - 'a'] = put(node.next[string[idx + 1] - 'a'], string, idx + 1);
}
return node;
}
class TrieNode {
char character;
TrieNode[] next;
boolean isTerminal, isLeaf;
boolean canWin, canLose;
TrieNode(char c, boolean isTerminallll) {
character = c;
isTerminal = isTerminallll;
next = new TrieNode[26];
isLeaf = true;
}
}
}
static class Edge implements Comparable<Edge> {
int from, to;
long weight, ans;
int id;
// int hash;
Edge(int fro, int t, long wt, int i) {
from = fro;
to = t;
id = i;
weight = wt;
// hash = Objects.hash(from, to, weight);
}
/*public int hashCode() {
return hash;
}*/
public int compareTo(Edge that) {
return Long.compare(this.id, that.id);
}
}
public static long[][] minSparseTable(long[] a)
{
int n = a.length;
int b = 32-Integer.numberOfLeadingZeros(n);
long[][] ret = new long[b][];
for(int i = 0, l = 1;i < b;i++, l*=2) {
if(i == 0) {
ret[i] = a;
}else {
ret[i] = new long[n-l+1];
for(int j = 0;j < n-l+1;j++) {
ret[i][j] = Math.min(ret[i-1][j], ret[i-1][j+l/2]);
}
}
}
return ret;
}
public static long sparseRangeMinQ(long[][] table, int l, int r)
{
// [a,b)
if(l >= r)return Integer.MAX_VALUE;
// 1:0, 2:1, 3:1, 4:2, 5:2, 6:2, 7:2, 8:3
int t = 31-Integer.numberOfLeadingZeros(r-l);
return Math.min(table[t][l], table[t][r-(1<<t)]);
}
public static long[][] maxSparseTable(long[] a)
{
int n = a.length;
int b = 32-Integer.numberOfLeadingZeros(n);
long[][] ret = new long[b][];
for(int i = 0, l = 1;i < b;i++, l*=2) {
if(i == 0) {
ret[i] = a;
}else {
ret[i] = new long[n-l+1];
for(int j = 0;j < n-l+1;j++) {
ret[i][j] = Math.max(ret[i-1][j], ret[i-1][j+l/2]);
}
}
}
return ret;
}
public static long sparseRangeMaxQ(long[][] table, int l, int r)
{
// [a,b)
if(l >= r)return Integer.MIN_VALUE;
// 1:0, 2:1, 3:1, 4:2, 5:2, 6:2, 7:2, 8:3
int t = 31-Integer.numberOfLeadingZeros(r-l);
return Math.max(table[t][l], table[t][r-(1<<t)]);
}
static class LCA {
int[] height, first, segtree;
ArrayList<Integer> euler;
boolean[] visited;
int n;
LCA(UGraph ug, int root) {
n = ug.V();
height = new int[n];
first = new int[n];
euler = new ArrayList<>();
visited = new boolean[n];
dfs(ug, root, 0);
int m = euler.size();
segtree = new int[m * 4];
build(1, 0, m - 1);
}
void dfs(UGraph ug, int node, int h) {
visited[node] = true;
height[node] = h;
first[node] = euler.size();
euler.add(node);
for (int adj : ug.adj(node)) {
if (!visited[adj]) {
dfs(ug, adj, h + 1);
euler.add(node);
}
}
}
void build(int node, int b, int e) {
if (b == e) {
segtree[node] = euler.get(b);
} else {
int mid = (b + e) / 2;
build(node << 1, b, mid);
build(node << 1 | 1, mid + 1, e);
int l = segtree[node << 1], r = segtree[node << 1 | 1];
segtree[node] = (height[l] < height[r]) ? l : r;
}
}
int query(int node, int b, int e, int L, int R) {
if (b > R || e < L)
return -1;
if (b >= L && e <= R)
return segtree[node];
int mid = (b + e) >> 1;
int left = query(node << 1, b, mid, L, R);
int right = query(node << 1 | 1, mid + 1, e, L, R);
if (left == -1) return right;
if (right == -1) return left;
return height[left] < height[right] ? left : right;
}
int lca(int u, int v) {
int left = first[u], right = first[v];
if (left > right) {
int temp = left;
left = right;
right = temp;
}
return query(1, 0, euler.size() - 1, left, right);
}
}
static class FenwickTree {
long[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates
public FenwickTree(int size) {
array = new long[size + 1];
}
public long rsq(int ind) {
assert ind > 0;
long sum = 0;
while (ind > 0) {
sum += array[ind];
//Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
ind -= ind & (-ind);
}
return sum;
}
public long rsq(int a, int b) {
assert b >= a && a > 0 && b > 0;
return rsq(b) - rsq(a - 1);
}
public void update(int ind, long value) {
assert ind > 0;
while (ind < array.length) {
array[ind] += value;
//Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
ind += ind & (-ind);
}
}
public int size() {
return array.length - 1;
}
}
static class Point implements Comparable<Point> {
long x;
long y;
long z;
long id;
// private int hashCode;
Point() {
x = z = y = 0;
// this.hashCode = Objects.hash(x, y, cost);
}
Point(Point p) {
this.x = p.x;
this.y = p.y;
this.z = p.z;
this.id = p.id;
// this.hashCode = Objects.hash(x, y, cost);
}
Point(long x, long y, long z, long id) {
this.x = x;
this.y = y;
this.z = z;
this.id = id;
// this.hashCode = Objects.hash(x, y, id);
}
Point(long a, long b) {
this.x = a;
this.y = b;
this.z = 0;
// this.hashCode = Objects.hash(a, b);
}
Point(long x, long y, long id) {
this.x = x;
this.y = y;
this.id = id;
}
@Override
public int compareTo(Point o) {
if (this.x < o.x)
return -1;
if (this.x > o.x)
return 1;
if (this.y < o.y)
return -1;
if (this.y > o.y)
return 1;
if (this.z < o.z)
return -1;
if (this.z > o.z)
return 1;
return 0;
}
@Override
public boolean equals(Object that) {
return this.compareTo((Point) that) == 0;
}
}
static class BinaryLift {
// FUNCTIONS: k-th ancestor and LCA in log(n)
int[] parentOf;
int maxJmpPow;
int[][] binAncestorOf;
int n;
int[] lvlOf;
// How this works?
// a. For every node, we store the b-ancestor for b in {1, 2, 4, 8, .. log(n)}.
// b. When we need k-ancestor, we represent 'k' in binary and for each set bit, we
// lift level in the tree.
public BinaryLift(UGraph tree) {
n = tree.V();
maxJmpPow = logk(n, 2) + 1;
parentOf = new int[n];
binAncestorOf = new int[n][maxJmpPow];
lvlOf = new int[n];
for (int i = 0; i < n; i++)
Arrays.fill(binAncestorOf[i], -1);
parentConstruct(0, -1, tree, 0);
binConstruct();
}
// TODO: Implement lvlOf[] initialization
public BinaryLift(int[] parentOf) {
this.parentOf = parentOf;
n = parentOf.length;
maxJmpPow = logk(n, 2) + 1;
binAncestorOf = new int[n][maxJmpPow];
lvlOf = new int[n];
for (int i = 0; i < n; i++)
Arrays.fill(binAncestorOf[i], -1);
UGraph tree = new UGraph(n);
for (int i = 1; i < n; i++)
tree.addEdge(i, parentOf[i]);
binConstruct();
parentConstruct(0, -1, tree, 0);
}
private void parentConstruct(int current, int from, UGraph tree, int depth) {
parentOf[current] = from;
lvlOf[current] = depth;
for (int adj : tree.adj(current))
if (adj != from)
parentConstruct(adj, current, tree, depth + 1);
}
private void binConstruct() {
for (int node = 0; node < n; node++)
for (int lvl = 0; lvl < maxJmpPow; lvl++)
binConstruct(node, lvl);
}
private int binConstruct(int node, int lvl) {
if (node < 0)
return -1;
if (lvl == 0)
return binAncestorOf[node][lvl] = parentOf[node];
if (node == 0)
return binAncestorOf[node][lvl] = -1;
if (binAncestorOf[node][lvl] != -1)
return binAncestorOf[node][lvl];
return binAncestorOf[node][lvl] = binConstruct(binConstruct(node, lvl - 1), lvl - 1);
}
// return ancestor which is 'k' levels above this one
public int ancestor(int node, int k) {
if (node < 0)
return -1;
if (node == 0)
if (k == 0) return node;
else return -1;
if (k > (1 << maxJmpPow) - 1)
return -1;
if (k == 0)
return node;
int ancestor = node;
int highestBit = Integer.highestOneBit(k);
while (k > 0 && ancestor != -1) {
ancestor = binAncestorOf[ancestor][logk(highestBit, 2)];
k -= highestBit;
highestBit = Integer.highestOneBit(k);
}
return ancestor;
}
public int lca(int u, int v) {
if (u == v)
return u;
// The invariant will be that 'u' is below 'v' initially.
if (lvlOf[u] < lvlOf[v]) {
int temp = u;
u = v;
v = temp;
}
// Equalizing the levels.
u = ancestor(u, lvlOf[u] - lvlOf[v]);
if (u == v)
return u;
// We will now raise level by largest fitting power of two until possible.
for (int power = maxJmpPow - 1; power > -1; power--)
if (binAncestorOf[u][power] != binAncestorOf[v][power]) {
u = binAncestorOf[u][power];
v = binAncestorOf[v][power];
}
return ancestor(u, 1);
}
}
static class DFSTree {
// NOTE: The thing is made keeping in mind that the whole
// input graph is connected.
UGraph tree;
UGraph backUG;
int hasBridge;
int n;
Edge backEdge;
DFSTree(UGraph ug) {
this.n = ug.V();
tree = new UGraph(n);
hasBridge = -1;
backUG = new UGraph(n);
treeCalc(0, -1, new boolean[n], ug);
}
private void treeCalc(int current, int from, boolean[] marked, UGraph ug) {
if (marked[current]) {
// This is a backEdge.
backUG.addEdge(from, current);
backEdge = new Edge(from, current, 1, 0);
return;
}
if (from != -1)
tree.addEdge(from, current);
marked[current] = true;
for (int adj : ug.adj(current))
if (adj != from)
treeCalc(adj, current, marked, ug);
}
public boolean hasBridge() {
if (hasBridge != -1)
return (hasBridge == 1);
// We have to determine the bridge.
bridgeFinder();
return (hasBridge == 1);
}
int[] levelOf;
int[] dp;
private void bridgeFinder() {
// Finding the level of each node.
levelOf = new int[n];
levelDFS(0, -1, 0);
// Applying DP solution.
// dp[i] -> Highest level reachable from subtree of 'i' using
// some backEdge.
dp = new int[n];
Arrays.fill(dp, Integer.MAX_VALUE / 100);
dpDFS(0, -1);
// Now, we will check each edge and determine whether its a
// bridge.
for (int i = 0; i < n; i++)
for (int adj : tree.adj(i)) {
// (i -> adj) is the edge.
if (dp[adj] > levelOf[i])
hasBridge = 1;
}
if (hasBridge != 1)
hasBridge = 0;
}
private void levelDFS(int current, int from, int lvl) {
levelOf[current] = lvl;
for (int adj : tree.adj(current))
if (adj != from)
levelDFS(adj, current, lvl + 1);
}
private int dpDFS(int current, int from) {
dp[current] = levelOf[current];
for (int back : backUG.adj(current))
dp[current] = Math.min(dp[current], levelOf[back]);
for (int adj : tree.adj(current))
if (adj != from)
dp[current] = Math.min(dp[current], dpDFS(adj, current));
return dp[current];
}
}
static class UnionFind {
// Uses weighted quick-union with path compression.
private int[] parent; // parent[i] = parent of i
private int[] size; // size[i] = number of sites in tree rooted at i
// Note: not necessarily correct if i is not a root node
private int count; // number of components
public UnionFind(int n) {
count = n;
parent = new int[n];
size = new int[n];
for (int i = 0; i < n; i++) {
parent[i] = i;
size[i] = 1;
}
}
// Number of connected components.
public int count() {
return count;
}
// Find the root of p.
public int find(int p) {
while (p != parent[p])
p = parent[p];
return p;
}
public boolean connected(int p, int q) {
return find(p) == find(q);
}
public int numConnectedTo(int node) {
return size[find(node)];
}
// Weighted union.
public void union(int p, int q) {
int rootP = find(p);
int rootQ = find(q);
if (rootP == rootQ) return;
// make smaller root point to larger one
if (size[rootP] < size[rootQ]) {
parent[rootP] = rootQ;
size[rootQ] += size[rootP];
}
else {
parent[rootQ] = rootP;
size[rootP] += size[rootQ];
}
count--;
}
public static int[] connectedComponents(UnionFind uf) {
// We can do this in nlogn.
int n = uf.size.length;
int[] compoColors = new int[n];
for (int i = 0; i < n; i++)
compoColors[i] = uf.find(i);
HashMap<Integer, Integer> oldToNew = new HashMap<>();
int newCtr = 0;
for (int i = 0; i < n; i++) {
int thisOldColor = compoColors[i];
Integer thisNewColor = oldToNew.get(thisOldColor);
if (thisNewColor == null)
thisNewColor = newCtr++;
oldToNew.put(thisOldColor, thisNewColor);
compoColors[i] = thisNewColor;
}
return compoColors;
}
}
static class UGraph {
// Adjacency list.
private HashSet<Integer>[] adj;
private static final String NEWLINE = "\n";
private int E;
@SuppressWarnings("unchecked")
public UGraph(int V) {
adj = (HashSet<Integer>[]) new HashSet[V];
E = 0;
for (int i = 0; i < V; i++)
adj[i] = new HashSet<Integer>();
}
public void addEdge(int from, int to) {
if (adj[from].contains(to)) return;
E++;
adj[from].add(to);
adj[to].add(from);
}
public HashSet<Integer> adj(int from) {
return adj[from];
}
public int degree(int v) {
return adj[v].size();
}
public int V() {
return adj.length;
}
public int E() {
return E;
}
public String toString() {
StringBuilder s = new StringBuilder();
s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
for (int v = 0; v < V(); v++) {
s.append(v + ": ");
for (int w : adj[v]) {
s.append(w + " ");
}
s.append(NEWLINE);
}
return s.toString();
}
public static void dfsMark(int current, boolean[] marked, UGraph g) {
if (marked[current]) return;
marked[current] = true;
Iterable<Integer> adj = g.adj(current);
for (int adjc : adj)
dfsMark(adjc, marked, g);
}
public static void dfsMark(int current, int from, long[] distTo, boolean[] marked, UGraph g, ArrayList<Integer> endPoints) {
if (marked[current]) return;
marked[current] = true;
if (from != -1)
distTo[current] = distTo[from] + 1;
HashSet<Integer> adj = g.adj(current);
int alreadyMarkedCtr = 0;
for (int adjc : adj) {
if (marked[adjc]) alreadyMarkedCtr++;
dfsMark(adjc, current, distTo, marked, g, endPoints);
}
if (alreadyMarkedCtr == adj.size())
endPoints.add(current);
}
public static void bfsOrder(int current, UGraph g) {
}
public static void dfsMark(int current, int[] colorIds, int color, UGraph g) {
if (colorIds[current] != -1) return;
colorIds[current] = color;
Iterable<Integer> adj = g.adj(current);
for (int adjc : adj)
dfsMark(adjc, colorIds, color, g);
}
public static int[] connectedComponents(UGraph g) {
int n = g.V();
int[] componentId = new int[n];
Arrays.fill(componentId, -1);
int colorCtr = 0;
for (int i = 0; i < n; i++) {
if (componentId[i] != -1) continue;
dfsMark(i, componentId, colorCtr, g);
colorCtr++;
}
return componentId;
}
public static boolean hasCycle(UGraph ug) {
int n = ug.V();
boolean[] marked = new boolean[n];
boolean[] hasCycleFirst = new boolean[1];
for (int i = 0; i < n; i++) {
if (marked[i]) continue;
hcDfsMark(i, ug, marked, hasCycleFirst, -1);
}
return hasCycleFirst[0];
}
// Helper for hasCycle.
private static void hcDfsMark(int current, UGraph ug, boolean[] marked, boolean[] hasCycleFirst, int parent) {
if (marked[current]) return;
if (hasCycleFirst[0]) return;
marked[current] = true;
HashSet<Integer> adjc = ug.adj(current);
for (int adj : adjc) {
if (marked[adj] && adj != parent && parent != -1) {
hasCycleFirst[0] = true;
return;
}
hcDfsMark(adj, ug, marked, hasCycleFirst, current);
}
}
}
static class Digraph {
// Adjacency list.
private HashSet<Integer>[] adj;
private static final String NEWLINE = "\n";
private int E;
@SuppressWarnings("unchecked")
public Digraph(int V) {
adj = (HashSet<Integer>[]) new HashSet[V];
E = 0;
for (int i = 0; i < V; i++)
adj[i] = new HashSet<Integer>();
}
public void addEdge(int from, int to) {
if (adj[from].contains(to)) return;
E++;
adj[from].add(to);
}
public HashSet<Integer> adj(int from) {
return adj[from];
}
public int V() {
return adj.length;
}
public int E() {
return E;
}
public Digraph reversed() {
Digraph dg = new Digraph(V());
for (int i = 0; i < V(); i++)
for (int adjVert : adj(i)) dg.addEdge(adjVert, i);
return dg;
}
public String toString() {
StringBuilder s = new StringBuilder();
s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
for (int v = 0; v < V(); v++) {
s.append(v + ": ");
for (int w : adj[v]) {
s.append(w + " ");
}
s.append(NEWLINE);
}
return s.toString();
}
public static int[] KosarajuSharirSCC(Digraph dg) {
int[] id = new int[dg.V()];
Digraph reversed = dg.reversed();
// Gotta perform topological sort on this one to get the stack.
Stack<Integer> revStack = Digraph.topologicalSort(reversed);
// Initializing id and idCtr.
id = new int[dg.V()];
int idCtr = -1;
// Creating a 'marked' array.
boolean[] marked = new boolean[dg.V()];
while (!revStack.isEmpty()) {
int vertex = revStack.pop();
if (!marked[vertex])
sccDFS(dg, vertex, marked, ++idCtr, id);
}
return id;
}
private static void sccDFS(Digraph dg, int source, boolean[] marked, int idCtr, int[] id) {
marked[source] = true;
id[source] = idCtr;
for (Integer adjVertex : dg.adj(source))
if (!marked[adjVertex]) sccDFS(dg, adjVertex, marked, idCtr, id);
}
public static Stack<Integer> topologicalSort(Digraph dg) {
// dg has to be a directed acyclic graph.
// We'll have to run dfs on the digraph and push the deepest nodes on stack first.
// We'll need a Stack<Integer> and a int[] marked.
Stack<Integer> topologicalStack = new Stack<Integer>();
boolean[] marked = new boolean[dg.V()];
// Calling dfs
for (int i = 0; i < dg.V(); i++)
if (!marked[i])
runDfs(dg, topologicalStack, marked, i);
return topologicalStack;
}
static void runDfs(Digraph dg, Stack<Integer> topologicalStack, boolean[] marked, int source) {
marked[source] = true;
for (Integer adjVertex : dg.adj(source))
if (!marked[adjVertex])
runDfs(dg, topologicalStack, marked, adjVertex);
topologicalStack.add(source);
}
}
static class FastReader {
private BufferedReader bfr;
private StringTokenizer st;
public FastReader() {
bfr = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
if (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(bfr.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());
}
char nextChar() {
return next().toCharArray()[0];
}
String nextString() {
return next();
}
int[] nextIntArray(int n) {
int[] arr = new int[n];
for (int i = 0; i < n; i++)
arr[i] = nextInt();
return arr;
}
double[] nextDoubleArray(int n) {
double[] arr = new double[n];
for (int i = 0; i < arr.length; i++)
arr[i] = nextDouble();
return arr;
}
long[] nextLongArray(int n) {
long[] arr = new long[n];
for (int i = 0; i < n; i++)
arr[i] = nextLong();
return arr;
}
int[][] nextIntGrid(int n, int m) {
int[][] grid = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
grid[i][j] = fr.nextInt();
}
return grid;
}
}
@SuppressWarnings("serial")
static class CountMap<T> extends TreeMap<T, Integer>{
CountMap() {
}
CountMap(Comparator<T> cmp) {
}
CountMap(T[] arr) {
this.putCM(arr);
}
public Integer putCM(T key) {
return super.put(key, super.getOrDefault(key, 0) + 1);
}
public Integer removeCM(T key) {
int count = super.getOrDefault(key, -1);
if (count == -1) return -1;
if (count == 1)
return super.remove(key);
else
return super.put(key, count - 1);
}
public Integer getCM(T key) {
return super.getOrDefault(key, 0);
}
public void putCM(T[] arr) {
for (T l : arr)
this.putCM(l);
}
}
static long dioGCD(long a, long b, long[] x0, long[] y0) {
if (b == 0) {
x0[0] = 1;
y0[0] = 0;
return a;
}
long[] x1 = new long[1], y1 = new long[1];
long d = dioGCD(b, a % b, x1, y1);
x0[0] = y1[0];
y0[0] = x1[0] - y1[0] * (a / b);
return d;
}
static boolean diophantine(long a, long b, long c, long[] x0, long[] y0, long[] g) {
g[0] = dioGCD(Math.abs(a), Math.abs(b), x0, y0);
if (c % g[0] > 0) {
return false;
}
x0[0] *= c / g[0];
y0[0] *= c / g[0];
if (a < 0) x0[0] = -x0[0];
if (b < 0) y0[0] = -y0[0];
return true;
}
static long[][] prod(long[][] mat1, long[][] mat2) {
int n = mat1.length;
long[][] prod = new long[n][n];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
// determining prod[i][j]
// it will be the dot product of mat1[i][] and mat2[][i]
for (int k = 0; k < n; k++)
prod[i][j] += mat1[i][k] * mat2[k][j];
return prod;
}
static long[][] matExpo(long[][] mat, long power) {
int n = mat.length;
long[][] ans = new long[n][n];
if (power == 0)
return null;
if (power == 1)
return mat;
long[][] half = matExpo(mat, power / 2);
ans = prod(half, half);
if (power % 2 == 1) {
ans = prod(ans, mat);
}
return ans;
}
static int KMPNumOcc(char[] text, char[] pat) {
int n = text.length;
int m = pat.length;
char[] patPlusText = new char[n + m + 1];
for (int i = 0; i < m; i++)
patPlusText[i] = pat[i];
patPlusText[m] = '^'; // Seperator
for (int i = 0; i < n; i++)
patPlusText[m + i] = text[i];
int[] fullPi = piCalcKMP(patPlusText);
int answer = 0;
for (int i = 0; i < n + m + 1; i++)
if (fullPi[i] == m)
answer++;
return answer;
}
static int[] piCalcKMP(char[] s) {
int n = s.length;
int[] pi = new int[n];
for (int i = 1; i < n; i++) {
int j = pi[i - 1];
while (j > 0 && s[i] != s[j])
j = pi[j - 1];
if (s[i] == s[j])
j++;
pi[i] = j;
}
return pi;
}
static boolean[] prefMatchesSuff(char[] s) {
int n = s.length;
boolean[] res = new boolean[n + 1];
int[] pi = prefix_function(s);
res[0] = true;
for (int p = n; p != 0; p = pi[p])
res[p] = true;
return res;
}
static int[] prefix_function(char[] s) {
int n = s.length;
int[] pi = new int[n];
for (int i = 1; i < n; i++) {
int j = pi[i-1];
while (j > 0 && s[i] != s[j])
j = pi[j-1];
if (s[i] == s[j])
j++;
pi[i] = j;
}
return pi;
}
static long hash(long key) {
long h = Long.hashCode(key);
h ^= (h >>> 20) ^ (h >>> 12) ^ (h >>> 7) ^ (h >>> 4);
return h & (gigamod-1);
}
static void Yes() {out.println("Yes");}static void YES() {out.println("YES");}static void yes() {out.println("Yes");}static void No() {out.println("No");}static void NO() {out.println("NO");}static void no() {out.println("no");}
static int mapTo1D(int row, int col, int n, int m) {
// Maps elements in a 2D matrix serially to elements in
// a 1D array.
return row * m + col;
}
static int[] mapTo2D(int idx, int n, int m) {
// Inverse of what the one above does.
int[] rnc = new int[2];
rnc[0] = idx / m;
rnc[1] = idx % m;
return rnc;
}
static long mapTo1D(long row, long col, long n, long m) {
// Maps elements in a 2D matrix serially to elements in
// a 1D array.
return row * m + col;
}
static boolean[] primeGenerator(int upto) {
// Sieve of Eratosthenes:
isPrime = new boolean[upto + 1];
smallestFactorOf = new int[upto + 1];
Arrays.fill(smallestFactorOf, 1);
Arrays.fill(isPrime, true);
isPrime[1] = isPrime[0] = false;
for (long i = 2; i < upto + 1; i++)
if (isPrime[(int) i]) {
smallestFactorOf[(int) i] = (int) i;
// Mark all the multiples greater than or equal
// to the square of i to be false.
for (long j = i; j * i < upto + 1; j++) {
if (isPrime[(int) j * (int) i]) {
isPrime[(int) j * (int) i] = false;
smallestFactorOf[(int) j * (int) i] = (int) i;
}
}
}
return isPrime;
}
static HashMap<Integer, Integer> smolNumPrimeFactorization(int num) {
if (smallestFactorOf == null)
primeGenerator(num + 1);
HashMap<Integer, Integer> fnps = new HashMap<>();
while (num != 1) {
fnps.put(smallestFactorOf[num], fnps.getOrDefault(smallestFactorOf[num], 0) + 1);
num /= smallestFactorOf[num];
}
return fnps;
}
static HashMap<Long, Integer> primeFactorization(long num) {
// Returns map of factor and its power in the number.
HashMap<Long, Integer> map = new HashMap<>();
while (num % 2 == 0) {
num /= 2;
Integer pwrCnt = map.get(2L);
map.put(2L, pwrCnt != null ? pwrCnt + 1 : 1);
}
for (long i = 3; i * i <= num; i += 2) {
while (num % i == 0) {
num /= i;
Integer pwrCnt = map.get(i);
map.put(i, pwrCnt != null ? pwrCnt + 1 : 1);
}
}
// If the number is prime, we have to add it to the
// map.
if (num != 1)
map.put(num, 1);
return map;
}
static HashSet<Long> divisors(long num) {
HashSet<Long> divisors = new HashSet<Long>();
divisors.add(1L);
divisors.add(num);
for (long i = 2; i * i <= num; i++) {
if (num % i == 0) {
divisors.add(num/i);
divisors.add(i);
}
}
return divisors;
}
static void coprimeGenerator(int m, int n, ArrayList<Point> coprimes, int limit, int numCoprimes) {
if (m > limit) return;
if (m <= limit && n <= limit)
coprimes.add(new Point(m, n));
if (coprimes.size() > numCoprimes) return;
coprimeGenerator(2 * m - n, m, coprimes, limit, numCoprimes);
coprimeGenerator(2 * m + n, m, coprimes, limit, numCoprimes);
coprimeGenerator(m + 2 * n, n, coprimes, limit, numCoprimes);
}
static long nCr(long n, long r, long[] fac) { long p = gigamod; if (r == 0) return 1; return (fac[(int)n] * modInverse(fac[(int)r], p) % p * modInverse(fac[(int)n - (int)r], p) % p) % p; }
static long modInverse(long n, long p) { return power(n, p - 2, p); }
static long modDiv(long a, long b){return mod(a * power(b, mod - 2, mod), mod);}
static long power(long x, long y, long p) { long res = 1; x = x % p; while (y > 0) { if ((y & 1)==1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }
static int logk(long n, long k) { return (int)(Math.log(n) / Math.log(k)); }
static long gcd(long a, long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static int gcd(int a, int b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static long gcd(long[] arr) { int n = arr.length; long gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static int gcd(int[] arr) { int n = arr.length; int gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static long lcm(long[] arr) { long lcm = arr[0]; int n = arr.length; for (int i = 1; i < n; i++) { lcm = (lcm * arr[i]) / gcd(lcm, arr[i]); } return lcm; } static long lcm(long a, long b) { return (a * b)/gcd(a, b); } static boolean less(int a, int b) { return a < b ? true : false; } static boolean isSorted(int[] a) { for (int i = 1; i < a.length; i++) { if (less(a[i], a[i - 1])) return false; } return true; } static boolean isSorted(long[] a) { for (int i = 1; i < a.length; i++) { if (a[i] < a[i - 1]) return false; } return true; } static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(long[] a, int i, int j) { long temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(double[] a, int i, int j) { double temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(char[] a, int i, int j) { char temp = a[i]; a[i] = a[j]; a[j] = temp; }
static void sort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void reverseSort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverse(char[] arr) { int n = arr.length; for (int i = 0; i < n / 2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); }
static void shuffleArray(long[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { long tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } } static void shuffleArray(int[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { int tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
static void shuffleArray(double[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { double tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
static void shuffleArray(char[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { char tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
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(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
static String toString(int[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
static String toString(boolean[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
static String toString(long[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
static String toString(char[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+"");return sb.toString();}
static String toString(int[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
static String toString(long[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++) {sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
static String toString(double[][] dp){StringBuilder sb=new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
static String toString(char[][] dp){StringBuilder sb = new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+"");}sb.append('\n');}return sb.toString();}
static long mod(long a, long m){return(a%m+1000000L*m)%m;}
}
/*
*
* int[] arr = new int[] {1810, 1700, 1710, 2320, 2000, 1785, 1780
, 2130, 2185, 1430, 1460, 1740, 1860, 1100, 1905, 1650};
int n = arr.length;
sort(arr);
int bel1700 = 0, bet1700n1900 = 0, abv1900 = 0;
for (int i = 0; i < n; i++)
if (arr[i] < 1700)
bel1700++;
else if (1700 <= arr[i] && arr[i] < 1900)
bet1700n1900++;
else if (arr[i] >= 1900)
abv1900++;
out.println("COUNT: " + n);
out.println("PERFS: " + toString(arr));
out.println("MEDIAN: " + arr[n / 2]);
out.println("AVERAGE: " + Arrays.stream(arr).average().getAsDouble());
out.println("[0, 1700): " + bel1700 + "/" + n);
out.println("[1700, 1900): " + bet1700n1900 + "/" + n);
out.println("[1900, 2400): " + abv1900 + "/" + n);
*
* */
// NOTES:
// ASCII VALUE OF 'A': 65
// ASCII VALUE OF 'a': 97
// Range of long: 9 * 10^18
// ASCII VALUE OF '0': 48
// Primes upto 'n' can be given by (n / (logn)). | 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 | 4bcf3cdca519f3e3920d997e263c53b1 | 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 //do not write package name here */
import java.util.*;
public class GFG {
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int o=0;o<t;o++){
HashSet<Integer> hs=new HashSet<>();
for(int i=1;i<10000;i++){
hs.add(i*i);
}
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++){
if(hs.contains(arr[i])==false) flag=true;
}
if(flag==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 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 | bb04697acecdc4e76f631f1dca4068d8 | 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 //do not write package name here */
import java.util.*;
public class GFG {
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
HashSet<Integer> hs=new HashSet<>();
for(int i=1;i<10000;i++){
hs.add(i*i);
}
int t=sc.nextInt();
for(int o=0;o<t;o++){
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++){
if(hs.contains(arr[i])==false) flag=true;
}
if(flag==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 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 | c39f849328f903c131707d09e9ed2311 | 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 //do not write package name here */
import java.util.*;
public class GFG {
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
HashSet<Integer> hs=new HashSet<>();
for(int i=1;i<100000;i++){
hs.add(i*i);
}
int t=sc.nextInt();
for(int o=0;o<t;o++){
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++){
if(hs.contains(arr[i])==false) flag=true;
}
if(flag==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 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 | 186dc03cee091a9384e2ee00ccd9904c | train_110.jsonl | 1618839300 | Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main{
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
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 long fac(long num) {
long ans = 1;
int mod = (int)1e9+7;
for(long i = 2;i<=num;i++) {
ans = (ans*i)%mod;
}
return ans;
}
public static int get(HashSet<Integer> set , char arr[]) {
int n = 0;
for(int i =0;i<arr.length;i++) {
if(set.contains(i)) continue;
n = n*10 + (arr[i] -'0');
}
return n;
}
public static String fun(String s , int l) {
String ans = "";
while(l-- > 0) {
ans += s;
}
return ans;
}
public static int getDivisor(int n) {
for(int i =n/2;i>=1;i--) {
if(n%i==0) return i;
}
return 1;
}
public static void main(String[] args)throws IOException {
FastReader sc = new FastReader();
int testCase = sc.nextInt();
while(testCase-- > 0 ) {
int n = sc.nextInt();
int arr[] = new int[n];
boolean ans = false;
for(int i =0;i<n;i++) {
arr[i] = sc.nextInt();
int x = (int)Math.sqrt(arr[i]);
if(x*x!=arr[i]) ans = true;
}
if(ans) System.out.println("YES");
else System.out.println("NO");
}
}
public static long fn(long n ) {
for(int i = 2;i<=n;i++) {
if(n%i==0) return i;
}
return n;
}
public static boolean isPowerOfTwo (long x) {
return x!=0 && ((x&(x-1)) == 0);
}
public static int[] getans(int num) {
int ans[] = new int[2];
int index =0;
for(int i =2;i<=num/2;i+=1) {
if(num%i==0)ans[index++] = i;
if(index==2 ) break;
}
return ans;
}
public static boolean isPrime(long num) {
if(num==1) return false;
if(num<=3) return true;
if(num%2==0||num%3==0) return false;
for(long i =5;i*i<=num;i+=6) {
if(num%i==0) return false;
}
return true;
}
public static boolean isPrime(int num) {
if(num==1) return false;
if(num<=3) return true;
if(num%2==0||num%3==0) return false;
for(int i =5;i*i<=num;i+=6) {
if(num%i==0) return false;
}
return true;
}
public static int gcd(int a , int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
public static long gcd(long a , long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
}
| 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 | b31920004c7c8f1d039016e8d892cdf5 | 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 A_Perfectly_imperfect_array {
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();
}
int count=0;
for (int i = 0; i < n; i++) {
int sqr=(int) Math.sqrt(arr[i]);
if((sqr*sqr)==arr[i]){
count++;
}
}
if(count==n){
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 | 763143657396caabc5c3ed573b796c20 | 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 CodeForces800_3 {
static Scanner sc;
public static void main(String[] args) {
sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0){
System.out.println(Process());
t--;
}
}
public static String Process(){
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++){
double temp=Math.sqrt(arr[i]);
if(temp-Math.floor(temp)!=0)
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 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 | 4cd9e21b68065299703f8361a8a87d26 | 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 A{
public static FastReader sc=new FastReader();
public static PrintWriter out = new PrintWriter(System.out);
public static void taskSolver(){
int n=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++)arr[i]=sc.nextInt();
boolean b=false;
for(int i=0;i<n;i++){
if(Math.ceil(Math.sqrt(arr[i]))!=Math.floor(Math.sqrt(arr[i]))){
b=true;break;
}
}
if(b)out.println("YES");
else out.println("NO");
}
public static void main(String args[]) throws java.lang.Exception{
int t=sc.nextInt();
while(t-->0)
taskSolver();
out.close();
}
class Pair{
int x,y;
Pair(int x,int y){
this.x=x;this.y=y;
}
}
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 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 | ab4176b4c68b552ab5f9e918e795e688 | 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 A{
public static FastReader sc=new FastReader();
public static PrintWriter out = new PrintWriter(System.out);
public static void taskSolver(){
int n=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++)arr[i]=sc.nextInt();
boolean b=false;
for(int i=0;i<n;i++){
if(arr[i]!=(int)Math.sqrt(arr[i])*(int)Math.sqrt(arr[i])){
b=true;break;
}
}
if(b)out.println("YES");
else out.println("NO");
}
public static void main(String args[]) throws java.lang.Exception{
int t=sc.nextInt();
while(t-->0)
taskSolver();
out.close();
}
class Pair{
int x,y;
Pair(int x,int y){
this.x=x;this.y=y;
}
}
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 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 | 9bc4bd44311dcfa7d4a13680727535eb | 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 Student {
public static void main(String [] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for(int i=0 ; i<t ; i++) {
boolean x = true;
int n = scan.nextInt();
int []arr = new int[n];
for(int l=0 ; l<n ; l++) {
arr[l] = scan.nextInt();
}
for(int k=0; k<n ; k++) {
long z = (long)Math.sqrt(arr[k]);
long zz = z*z;
if(zz!=arr[k]) {
x = false;
System.out.println("YES");
break;
}
}
if(x==true) {
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 | |
PASSED | 6a77679941f7da83185529ec63763332 | 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.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.lang.Math;
public class Account {
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 flag= false ;
for(int i=0 ;i<n ;i++ ) {
arr[i]= sc.nextInt() ;
if(isPerfectSquare(arr[i]) == false && flag == false) {
flag= true ;
// break ;
}
}
if(flag == true) {
System.out.println("YES");
}else {
System.out.println("NO");
}
}
}
static boolean isPerfectSquare(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 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 | 20f0b736e66f6507ee933b49bc76391a | 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.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.lang.Math;
public class Account {
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 flag= false ;
for(int i=0 ;i<n ;i++ ) {
arr[i]= sc.nextInt() ;
int sqrt= (int) Math.sqrt(arr[i]) ;
if(sqrt*sqrt != arr[i]) {
flag= true ;
// break ;
}
}
if(flag == 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 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 | 5a0c9a9d6fd9434ea2dfdc793039db8b | 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 in = new Scanner(System.in);
int t = in.nextInt();
while (t --> 0) {
int n = in.nextInt();
int[] arr = new int[n];
boolean perf = true;
for (int i = 0; i < n; i++)
{
arr[i] = in.nextInt();
int k = (int)Math.sqrt(arr[i]);
if (k * k != arr[i]) {
perf = false;
}
}
if (perf) {
System.out.println("NO");
}
else System.out.println("YES");
}
in.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 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 | 7fcb3909d5a208ed59c05c9afd1937a6 | 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();
while(t-->0)
{
boolean flag=false;
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)
flag=true;
}
System.out.println(flag?"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 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 | 8d2f715a62d7aa67455573217d084a9c | 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 codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
static boolean checkPerfectSquare(double number){
double sqrt=Math.sqrt(number);
return ((sqrt - Math.floor(sqrt)) == 0);
}
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[] arr = new int[n];
for(int i= 0; i < n; i++){
arr[i] = s.nextInt();
}
int i;
for(i = 0; i < n; i++){
if(!checkPerfectSquare(arr[i])){
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 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 | a6e08f9329156a52c0e97fab07de145e | 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 CodeTest {
public static String check(int arr[]){
for(int i : arr){
if(Math.sqrt(i) - Math.floor(Math.sqrt(i)) != 0){
return "YES";
}
}
return "NO";
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int numberTestCase = sc.nextInt();
for(int i = 1; i <= numberTestCase; i++){
int length = sc.nextInt();
int[] arr = new int[length];
for(int j = 0; j < length; j++){
arr[j] = sc.nextInt();
}
System.out.println(check(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 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 | 9f5a2160d7875d216a0d6edc712fcb58 | 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{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int T = in.nextInt();
for (int t=0; t<T; t++) {
int N = in.nextInt();
boolean found = false;
for (int n=0; n<N; n++) {
int a = in.nextInt();
int sqrt = (int) Math.sqrt(a);
found |= (sqrt*sqrt != a);
}
System.out.println(found ? "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 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 | de373b769c5ab4826edba3fc090f7931 | 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 cupballet {
static int[] B,A;
static int n,m;
static int[][] DP;
static boolean IsSquare(int N)
{
int i;
for(i=1; N>0; i+=2) //变化步长为2, 初值为1,一直减到N大于0
{
N-=i;
}
if(N==0)
return true; //如果N减到最后,恰好等于0,就是平方数
else
return false; //否则,就不是平方数
}
public static void main(String[] args)throws IOException {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
n = in.nextInt();
for(int x=0;x<n;x++) {
m = in.nextInt();
boolean flag = true;
for(int i=0;i<m;i++) {
int a = in.nextInt();
if(!IsSquare(a)&&flag==true) {
System.out.println("YES");
flag = false;
}
}
if(flag==true) {
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 | |
PASSED | 99331f33c0e69be26badf15226d7e6de | 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 cupballet {
static int[] B,A;
static int n,m;
static int[][] DP;
static boolean IsSquare(int N)
{
int i;
for(i=1; N>0; i+=2) //变化步长为2, 初值为1,一直减到N大于0
{
N-=i;
}
if(N==0)
return true; //如果N减到最后,恰好等于0,就是平方数
else
return false; //否则,就不是平方数
}
public static void main(String[] args)throws IOException {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
n = in.nextInt();
for(int x=0;x<n;x++) {
m = in.nextInt();
boolean flag = true;
for(int i=0;i<m;i++) {
int a = in.nextInt();
if(!IsSquare(a)&&flag==true) {
System.out.println("YES");
flag = false;
}
}
if(flag==true) {
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 | |
PASSED | 7bd5efef76e59c94422bfbf3076779ad | 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 Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Integer t = Integer.valueOf(sc.nextLine());
for (int i = 0; i < t; i++){
Integer s = Integer.valueOf(sc.nextLine());
String[] s1 = sc.nextLine().split(" ");
boolean f = false;
for (int j = 0; j < s; j++){
int val= Integer.valueOf(s1[j]);
if (!isPerfectSq(val)){
f = true;
break;
}
}
if (f)
System.out.println("YES");
else
System.out.println("NO");
}
}
public static boolean isPerfectSq(long n) {
if (n < 0) {
return false;
}
switch((int)(n & 0xF)) {
case 0: case 1: case 4: case 9:
long tst = (long)Math.sqrt(n);
return tst*tst == n;
default:
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 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 | 01d6ce4e75a1cbcaa0ed4704b7bd10bd | 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 Main {
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();
}
boolean flag = false;
for(int i=0;i<n;i++){
if((int)Math.sqrt(a[i]) * (int)Math.sqrt(a[i]) != a[i]){
System.out.println("Yes");
flag = true;
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 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 | beb0124ea21980e04175486a6c84e286 | 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 final class Solution {
static PrintWriter out = new PrintWriter(System.out);
static FastReader in = new FastReader();
static long mod = (long) 1e9 + 7;
static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, 1)};
public static void main(String[] args) {
int t = i();
out:
while (t-- > 0) {
int n = i();
int[] arr = input(n);
for (int x : arr) {
if (!isPS(x)) {
out.println("YES");
continue out;
}
}
out.println("NO");
}
out.flush();
}
public static boolean isPS(int x) {
if (x == 1) {
return true;
}
for (int i = 2; i <= x / 2; i++) {
if (i * i == x) {
return true;
}
}
return false;
}
public static long calc(int type, long X, long K) {
if (type == 1) {
return (X + 99999) / 100000 + K;
} else {
return (K * X + 99999) / 100000;
}
}
static int sd(long i) {
int d = 0;
while (i > 0) {
d += i % 10;
i = i / 10;
}
return d;
}
static int lower(long A[], long x) {
int l = -1, r = A.length;
while (r - l > 1) {
int m = (l + r) / 2;
if (A[m] >= x) {
r = m;
} else {
l = m;
}
}
return r;
}
static int upper(long A[], long x) {
int l = -1, r = A.length;
while (r - l > 1) {
int m = (l + r) / 2;
if (A[m] <= x) {
l = m;
} else {
r = m;
}
}
return l;
}
static void swap(int A[], int a, int b) {
int t = A[a];
A[a] = A[b];
A[b] = t;
}
static int lowerBound(int A[], int low, int high, int x) {
if (low > high) {
if (x >= A[high]) {
return A[high];
}
}
int mid = (low + high) / 2;
if (A[mid] == x) {
return A[mid];
}
if (mid > 0 && A[mid - 1] <= x && x < A[mid]) {
return A[mid - 1];
}
if (x < A[mid]) {
return lowerBound(A, low, mid - 1, x);
}
return lowerBound(A, mid + 1, high, x);
}
static long pow(long a, long b) {
long pow = 1;
long x = a;
while (b != 0) {
if ((b & 1) != 0) {
pow = (pow * x) % mod;
}
x = (x * x) % mod;
b /= 2;
}
return pow;
}
static 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 void print(char A[]) {
for (char c : A) {
out.print(c);
}
out.println();
}
static void print(boolean A[]) {
for (boolean c : A) {
out.print(c + " ");
}
out.println();
}
static void print(int A[]) {
for (int c : A) {
out.print(c + " ");
}
out.println();
}
static void print(long A[]) {
for (long i : A) {
out.print(i + " ");
}
out.println();
}
static void print(ArrayList<Integer> A) {
for (int a : A) {
out.print(a + " ");
}
}
static int i() {
return in.nextInt();
}
static long l() {
return in.nextLong();
}
static String s() {
return in.nextLine();
}
static int[] input(int N) {
int A[] = new int[N];
for (int i = 0; i < N; i++) {
A[i] = in.nextInt();
}
return A;
}
static long[] inputLong(int N) {
long A[] = new long[N];
for (int i = 0; i < A.length; i++) {
A[i] = in.nextLong();
}
return A;
}
static int GCD(int a, int b) {
if (b == 0) {
return a;
} else {
return GCD(b, a % b);
}
}
static long GCD(long a, long b) {
if (b == 0) {
return a;
} else {
return GCD(b, a % b);
}
}
}
class SegmentTree {
long[] t;
public SegmentTree(int n) {
t = new long[n + n];
Arrays.fill(t, Long.MIN_VALUE);
}
public long get(int i) {
return t[i + t.length / 2];
}
public void add(int i, long value) {
i += t.length / 2;
t[i] = value;
for (; i > 1; i >>= 1) {
t[i >> 1] = Math.max(t[i], t[i ^ 1]);
}
}
// max[a, b]
public long max(int a, int b) {
long res = Long.MIN_VALUE;
for (a += t.length / 2, b += t.length / 2; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1) {
if ((a & 1) != 0) {
res = Math.max(res, t[a]);
}
if ((b & 1) == 0) {
res = Math.max(res, t[b]);
}
}
return res;
}
}
class Pair {
int i, j;
Pair(int i, int j) {
this.i = i;
this.j = j;
}
}
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
| 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 | b1e32d9af1d5fcbd4beb4f1dff7df074 | 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 A_Perfectly_Imperfect_Array{
static void main() throws Exception{
int n=sc.nextInt();
int[]in=sc.intArr(n);
for(int i=0;i<n;i++) {
for(int p=2;p*p<=in[i];p++) {
if(in[i]%p!=0)continue;
int cnt=0;
while(in[i]%p==0) {
cnt^=1;
in[i]/=p;
}
if(cnt==1) {
pw.println("YES");
return;
}
}
if(in[i]>1) {
pw.println("YES");
return;
}
}
pw.println("NO");
}
public static void main(String[] args) throws Exception{
sc=new MScanner(System.in);
pw = new PrintWriter(System.out);
int tc=1;
tc=sc.nextInt();
for(int i=1;i<=tc;i++) {
// pw.printf("Case #%d:", i);
main();
}
pw.flush();
}
static PrintWriter pw;
static MScanner sc;
static class MScanner {
StringTokenizer st;
BufferedReader br;
public MScanner(InputStream system) {
br = new BufferedReader(new InputStreamReader(system));
}
public MScanner(String file) throws Exception {
br = new BufferedReader(new FileReader(file));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int[] intArr(int n) throws IOException {
int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
return in;
}
public long[] longArr(int n) throws IOException {
long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
return in;
}
public int[] intSortedArr(int n) throws IOException {
int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
shuffle(in);
Arrays.sort(in);
return in;
}
public long[] longSortedArr(int n) throws IOException {
long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
shuffle(in);
Arrays.sort(in);
return in;
}
public Integer[] IntegerArr(int n) throws IOException {
Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
return in;
}
public Long[] LongArr(int n) throws IOException {
Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
return in;
}
public String nextLine() throws IOException {
return br.readLine();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public char nextChar() throws IOException {
return next().charAt(0);
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public boolean ready() throws IOException {
return br.ready();
}
public void waitForInput() throws InterruptedException {
Thread.sleep(3000);
}
}
static void sort(int[]in) {
shuffle(in);
Arrays.sort(in);
}
static void sort(long[]in) {
shuffle(in);
Arrays.sort(in);
}
static void shuffle(int[]in) {
for(int i=0;i<in.length;i++) {
int idx=(int)(Math.random()*in.length);
int tmp=in[i];
in[i]=in[idx];
in[idx]=tmp;
}
}
static void shuffle(long[]in) {
for(int i=0;i<in.length;i++) {
int idx=(int)(Math.random()*in.length);
long tmp=in[i];
in[i]=in[idx];
in[idx]=tmp;
}
}
}
| 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 | 9e92aac9baa94f718fe35db8e83f4621 | 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 MyCpClass
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args)
{
FastReader fs=new FastReader();
int t = fs.nextInt();
while(t-- > 0){
int n = fs.nextInt();
int []a = new int[n];
for(int i=0; i<n; i++)
a[i] = fs.nextInt();
String ans = "NO";
for(int i=0; i<n; i++){
int rt = (int)Math.sqrt(a[i]);
if(rt*rt != a[i]){
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 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 | 8b02427f7aedb58ccf4c54038d567d12 | 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)
{
boolean flag=false;
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)
flag=true;
}
System.out.println(flag?"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 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 | 985b010c5be1bfcbc630f5a23ff84d8a | 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.sql.Array;
import java.util.ArrayList;
import java.math.*;
import java.util.Scanner;
import static java.lang.Math.sqrt;
public class Main {
public static void main(String []args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while((--t)>=0)
{
int n = sc.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++)
arr[i] = sc.nextInt();
int f=0;
for(int i=0;i<n;i++)
{
int d = (int)Math.sqrt(arr[i]);
if(d*d !=arr[i])
{
f=1;
break;
}
}
if(f==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 | |
PASSED | 5bd8bd4b73b550b2d10342b1d60aeb22 | 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 codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
static boolean checkPerfectSquare(int x)
{
double zz = (double)x;
// finding the square root of given number
double sq = Math.sqrt(zz);
/* 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) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- != 0){
int n = sc.nextInt();
int a[] = new int [n];
long p = 1;
int fla = -1;
for(int i = 0 ; i < n ; i++){
a[i] = sc.nextInt();
if(!checkPerfectSquare(a[i])){
fla = 1;
}
p *= a[i];
}
if(fla == 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 | |
PASSED | 913712a2f7b7c9833947e92674c92cce | 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 Experiment {
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();
}
if (Check(arr, n) == true) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
public static boolean Check(int[] arr, int n) {
for (int i = 0; i < n; i++) {
double count = (int) Math.sqrt(arr[i]);
// System.out.println(count);
// System.out.println(count * count);
if (count * count != arr[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 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 | 7f816e9da9b789fec044b169e1eff2c8 | train_110.jsonl | 1618839300 | Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements. | 256 megabytes | import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n= sc.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++){
arr[i] = sc.nextInt();
}
if(!solve(arr, n))
System.out.println("YES");
else
System.out.println("NO");
}
}
public static boolean solve(int[] arr, int n){
for(int i=0;i<n;i++){
int rt = (int)Math.sqrt(arr[i]);
if(rt*rt != arr[i])
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 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 | 60cebd5d40b4653868c9ecbad81f9563 | 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 A {
static class Reader{
private BufferedReader reader;
private StringTokenizer tokenizer;
Reader(InputStream input)
{
this.reader = new BufferedReader(new InputStreamReader(input));
this.tokenizer = new StringTokenizer("");
}
public String next() throws IOException {
while(!tokenizer.hasMoreTokens())
{
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
public int nextInt() throws IOException
{
return Integer.parseInt(next());
}
public double nextDouble() throws IOException
{
return Double.parseDouble(next());
}
public long nextLong() throws IOException
{
return Long.parseLong(next());
}
}
public static void main(String[] args) throws IOException{
Reader scan = new Reader(System.in);
BufferedOutputStream b = new BufferedOutputStream(System.out);
StringBuffer sb = new StringBuffer();
int Test = scan.nextInt();
while(Test-->0)
{
int N = scan.nextInt();
int[] arr = new int[N];
for(int i=0; i<N;i++)
{
arr[i] = scan.nextInt();
}
sb.append(solve(arr,N));
}
b.write((sb.toString()).getBytes());
b.flush();
}
private static String solve(int[] arr, int n) {
for(int i:arr)
{
if(isPerfectSquare(i)==false)return "YES\n";
}
return "NO\n";
}
public static boolean isPerfectSquare(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 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 | 07a2f76c59fb0448aeeca2c5536fe6c4 | 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_716_DIV_2;
import java.util.*;
import java.io.*;
public class A {
static class Reader{
private BufferedReader reader;
private StringTokenizer tokenizer;
Reader(InputStream input)
{
this.reader = new BufferedReader(new InputStreamReader(input));
this.tokenizer = new StringTokenizer("");
}
public String next() throws IOException {
while(!tokenizer.hasMoreTokens())
{
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
public int nextInt() throws IOException
{
return Integer.parseInt(next());
}
public double nextDouble() throws IOException
{
return Double.parseDouble(next());
}
public long nextLong() throws IOException
{
return Long.parseLong(next());
}
}
public static void main(String[] args) throws IOException{
Reader scan = new Reader(System.in);
BufferedOutputStream b = new BufferedOutputStream(System.out);
StringBuffer sb = new StringBuffer();
int Test = scan.nextInt();
while(Test-->0)
{
int N = scan.nextInt();
int[] arr = new int[N];
for(int i=0; i<N;i++)
{
arr[i] = scan.nextInt();
}
sb.append(solve(arr,N));
}
b.write((sb.toString()).getBytes());
b.flush();
}
private static String solve(int[] arr, int n) {
for(int i:arr)
{
if(isPerfectSquare(i)==false)return "YES\n";
}
return "NO\n";
}
public static boolean isPerfectSquare(int n)
{
int i = (int)Math.floor(Math.sqrt(n));
// for (int i = 1; i * i <= n; i++) {
// if ((n % i == 0) && (n / i == i)) {
// return true;
// }
// }
if(i*i==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 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 | 9198a81f6ee04d4bcfbf553cc0606dc3 | 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 aditya
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class PerfectlyImperfect {
public static void main(String[] args) {
FastScanner fs=new FastScanner();
int T=fs.nextInt();
PrintWriter out=new PrintWriter(System.out);
for (int tt=0; tt<T; tt++) {
boolean flag=false;
int n = fs.nextInt();
int arr[] = fs.readArray(n);
for(int i=0;i<n;i++){
if(!isPerfectSquare(arr[i]))
flag=true;
}
if(!flag)
out.println("NO");
else
out.println("YES");
}
out.close();
}
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;
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
public String next() {
while (!st.hasMoreElements())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
int nextInt () {
return Integer.parseInt(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 | 617de2250b04d4dff98d5b22d72be5ca | 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 | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.util.*;
public class Main
{
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();
}
boolean flag=false;
//long val=1;
for(int i=0;i<n;i++){
//val*=a[i];
if(Math.sqrt(a[i])!=(int)Math.sqrt(a[i])){
flag=true;
break;
}
}
if(!flag){
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 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 | ee53eda8cbb32c1d1f0d95c91dd8e2ac | 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.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
while(t-->0)
{
int n=Integer.parseInt(br.readLine());
String[] st=br.readLine().split(" ");
int[] a=new int[n];
for(int i=0;i<st.length;i++)
{
a[i]=Integer.parseInt(st[i]);
}
boolean fl=false;
for(int i=0;i<st.length;i++)
{
int x=(int)Math.floor(Math.sqrt(a[i]));
if(x*x!=a[i])
{
fl=true;
break;
}
}
if(fl)
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 | |
PASSED | 904aca787ad9b37f7fc6ceac879d89d7 | 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 div_2_716_a {
public static void main(String args[]){
FScanner in = new FScanner();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
while(t-->0) {
int n=in.nextInt();
int a[]=in.readArray(n);
double sum=1;
boolean flag=false;
for(int i=0;i<n;i++)
{
sum=sum*a[i];
}
if (Math.ceil((double)Math.sqrt(sum)) ==Math.floor((double)Math.sqrt(sum)))
{
for(int i=0;i<n;i++)
{
if (Math.ceil((double)Math.sqrt(a[i])) ==Math.floor((double)Math.sqrt(a[i])))
flag=true;
else
{flag=false;
break;}
}
if(flag==true)
out.println("No");
else
out.println("Yes");
}
else
out.println("Yes");
}
out.close();
}
static class FScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer sb = new StringTokenizer("");
String next(){
while(!sb.hasMoreTokens()){
try{
sb = new StringTokenizer(br.readLine());
} catch(IOException e){ }
}
return sb.nextToken();
}
String nextLine(){
try{ return br.readLine(); }
catch(IOException e) { } return "";
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
int[] readArray(int n) {
int a[] = new int[n];
for(int i=0;i<n;i++) a[i] = nextInt();
return a;
}
float nextFloat(){
return Float.parseFloat(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
}
}
| Java | ["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 | db193978a2f6222504351463a151607c | 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 scanner = new Scanner(System.in);
int t = scanner.nextInt();
for(int i=0;i<t;i++) {
int n = scanner.nextInt();
boolean flag = false;
for(int j=0;j<n;j++) {
int a = scanner.nextInt();
int sa = (int)Math.sqrt((double)a);
if(a!=sa*sa && !flag) {
flag = true;
System.out.println("YES");
}
}
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 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 | dfb22ab94abbe04afa52986aed75f02e | 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 A71 {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int i = s.nextInt();
while (i!=0) {
int n = s.nextInt();
boolean set = true;
while (n!=0) {
if (Math.sqrt((double) s.nextInt())%1!=0) { set = false; }
n--;
}
if (set) { System.out.println("NO"); }
else { System.out.println("YES"); }
i--;
}
}
}
| 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 | b3c90fe0f9e535695d1cd34bc67a216e | 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 A {
private final static Scanner scanner=new Scanner(System.in);
public static void main(String[] args){
int a;
int t=scanner.nextInt();
while (t--!=0){
int n=scanner.nextInt();
boolean flag=false;
for(int i=0;i<n;i++){
a=scanner.nextInt();
int s= (int) Math.sqrt(a);
if(s*s!=a){ //有一个数不是完全平方数,那么肯定存在
flag=true;
continue;
}
}
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 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 | acc0b83614e1a3c8462991a3d481d7ce | 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.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;
public class A {
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 go = true;
int j=0;
while(go) {
int a = sc.nextInt();
if(Math.sqrt(a)!=Math.floor(Math.sqrt(a))) {
System.out.println("YES");
go=false;
sc.nextLine();
}
else if(j==n-1) {
System.out.println("NO");
go=false;
}
j++;
}
}
}
}
| 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 | c6726f0d8b00b8579042a4e111e502d8 | 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.*;
public class ImperfectArray
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int runs = sc.nextInt();
while(runs-->0)
{
int n = sc.nextInt();
double[] arr = new double[n];
for(int i = 0;i<n;i++)
arr[i] = sc.nextDouble();
boolean fl = false;
outer:for(int i = 0;i<n;i++)
{
double answer = Math.sqrt(arr[i]);
if(answer-Math.floor(answer)!=0)
{
fl = true;
break;
}
}
System.out.println(fl?"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 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 | fe343d4f0ee703b06cf2d568bbdcb215 | 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 Main {
static int size;
static int[] arr;
static boolean isSquare(int num) {
double doubleSqrt = Math.sqrt(num);
int sqrt = (int) doubleSqrt;
return doubleSqrt == sqrt;
}
static boolean solve(int[] arr) {
for(int d : arr) {
if(!isSquare(d)) return false;
}
return true;
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int T = Integer.parseInt(br.readLine());
for(int t = 1; t <= T; t++) {
StringTokenizer st;
size = Integer.parseInt(br.readLine());
arr = new int[size];
st = new StringTokenizer(br.readLine());
for(int idx = 0; idx < size; idx++) {
arr[idx] = Integer.parseInt(st.nextToken());
}
sb.append(solve(arr) ? "NO" : "YES").append("\n");
}
System.out.println(sb);
}
} | 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 | 1a10728b61ebbd6dc2b3df863a70ea09 | 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 c716a
{
//By shwetank_verma
static boolean pref(double x)
{
if (x >= 0) {
// Find floating point value of
// square root of x.
double sr = Math.sqrt(x);
// if product of square root
// is equal, then
// return T/F
return ((sr * sr) == x);
}
return false;
}
public static void main(String[] args)
{
FastReader sc=new FastReader();
try{
int t=1;
t=sc.nextInt();
tsl: while(t-->0){
int n=sc.nextInt();
long a[]=new long[n];
boolean f=false;
int cnt=0;
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
double v=Math.sqrt(a[i]);
if(Math.ceil(v)==Math.floor(v))
{
cnt++;
}
}
if(cnt==n)
System.out.println("NO");
else
System.out.println("YES");
}
}catch(Exception e){
return;
}
}
static void ruffleSort(long[] a) {
int n=a.length;
Random r=new Random();
for (int i=0; i<a.length; i++) {
long oi=r.nextInt(n), temp=a[i];
a[i]=a[(int)oi];
a[(int)oi]=temp;
}
Arrays.sort(a);
}
static void ruffleSort(int[] a) {
int n=a.length;
Random r=new Random();
for (int i=0; i<a.length; i++) {
int oi=r.nextInt(n), temp=a[i];
a[i]=a[oi];
a[oi]=temp;
}
Arrays.sort(a);
}
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
static int mod=1000000007;
static boolean primes[]=new boolean[1000007];
static ArrayList<Integer> b=new ArrayList<>();
static boolean seive(int n){
Arrays.fill(primes,true);
primes[0]=primes[1]=false;
for(int i=2;i*i<=n;i++){
if(primes[i]==true){
for(int p=i*i;p<=n;p+=i){
primes[p]=false;
}
}
}
if(n<1000007){
for(int i=2;i<=n;i++) {
if(primes[i])
b.add(i);
}
return primes[n];
}
return false;
}
static int gcd(int a,int b){
if(b==0)
return a;
return gcd(b,a%b);
}
static long GCD(long a,long b){
if(b==0)
return a;
return GCD(b,a%b);
}
static ArrayList<Integer> segseive(int l,int r){
ArrayList<Integer> isprime=new ArrayList<Integer>();
boolean p[]=new boolean[r-l+1];
Arrays.fill(p, true);
for(int i=0;b.get(i)*b.get(i)<=r;i++) {
int currprime=b.get(i);
int base=(l/currprime)*currprime;
if(base<l) {
base+=currprime;
}
for(int j=base;j<=r;j+=currprime) {
p[j-l]=false;
}
if(base==currprime) {
p[base-l]=true;
}
}
for(int i=0;i<=r-l;i++) {
if(p[i])
isprime.add(i+l);
}
return isprime;
}
static int LowerBound(int a[], int x) { // x is the target value or key
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;
}
static int UpperBound(int a[], int x) {// x is the key or target value
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;
}
} | 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 | 3f77fbda41c6e4596021f975728b1763 | 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 Main {
public static void main(String args[])
{
FastReader input=new FastReader();
PrintWriter out=new PrintWriter(System.out);
int T=input.nextInt();
while(T-->0)
{
int n=input.nextInt();
int a[]=new int[n];
int flag=0;
int v=0;
HashSet<Integer> set=new HashSet<>();
for(int i=0;i<n;i++)
{
a[i]=input.nextInt();
set.add(a[i]);
int q=(int)Math.sqrt(a[i]);
if(q*q!=a[i])
{
v=a[i];
flag=1;
}
}
if(flag==1)
{
out.println("YES");
}
else
{
out.println("NO");
}
}
out.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 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 | 8c0a344d366fc47004ab0cf4480cd74f | 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.ArrayList;
import java.util.Scanner;
public class A1514 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
while(T--!=0){
boolean flag = true;
int size = sc.nextInt();
while(size--!=0)
{
int temp = sc.nextInt();
if(!isPerfect(temp)) flag = false;
}
if(!flag) System.out.println("YES");
else System.out.println("NO");
}
}
public static boolean isPerfect(int ele)
{
return(Math.ceil(Math.sqrt(ele)) == Math.floor(Math.sqrt(ele)));
}
}
| 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 | cfdf2656b3376948e88a8656d89d4a3b | 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 java.util.Map.Entry;
public class Codechef {
static ArrayList<Integer> adj[];
static long ans = 0;
static long above = 0;
static List<Integer> factors = new ArrayList<>();
static FastReader f = new FastReader();
static int mod = 1000000007;
public static void solve() {
int n = f.nextInt();
int a[] = new int[n];
for(int i = 0 ; i < n ; i++) {
a[i] = f.nextInt();
}
for(int i = 0 ; i < n ; i++) {
if(!checkPerfectSquare(a[i])) {
System.out.println("YES");
return;
}
}
System.out.println("NO");
}
public static void main(String[] args) throws IOException {
// FastReader f = new FastReader();
int t = f.nextInt();
// int t = 1;
for (int i = 0; i < t; i++) {
solve();
}
}
public static Map<Integer, Integer> primeFactors(int n)
{
// Print the number of 2s that divide n
Map<Integer, Integer> map = new HashMap<>();
int count = 0;
while (n%2==0)
{
// System.out.print(2 + " ");
count++;
n /= 2;
}
if(count > 0)
map.put(2, count);
// n must be odd at this point. So we can
// skip one element (Note i = i +2)
for (int i = 3; i <= Math.sqrt(n); i+= 2)
{
// While i divides n, print i and divide n
count = 0;
while (n%i == 0)
{
// System.out.print(i + " ");
count++;
n /= i;
}
if(count > 0)
map.put(i, count);
}
// This condition is to handle the case when
// n is a prime number greater than 2
if (n > 2)
map.put(n, map.getOrDefault(n, 0) + 1);
return map;
}
static List<Integer> sieveOfEratosthenes(int n)
{
List<Integer> list = new ArrayList();
boolean prime[] = new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++) {
// If prime[p] is not changed, then it is a
// prime
if (prime[p] == true) {
// Update all multiples of p
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
for (int i = 2; i <= n; i++) {
if (prime[i] == true) {
list.add(i);
}
}
return list;
}
public static int mex(List<Integer> a) {
int prev = 0;
int n = a.size();
for(int i = 0 ; i < n ; i++) {
int curr = a.get(i);
if(curr == prev || curr == prev + 1) {
prev = curr;
}
else {
return curr;
}
}
return a.get(n - 1)+1;
}
//
static List<Integer> getDivisors(long n) {
List<Integer> ans = new ArrayList();
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ans.add(i);
ans.add((int) (n / i));
}
}
return ans;
}
static void allFactors(int n) {
for (int i = 1; i <= Math.sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i)
factors.add(i); // divisors are equal then add only one of them.
else {
factors.add(i); // divisors are different thus add i, and n/i because i * n/i = n
factors.add(n / i);
}
}
}
}
public static boolean isLucky(int n) {
boolean flag = true;
int nn = n;
while (n > 0) {
if (n % 10 != 4 && n % 10 != 7) {
flag = false;
break;
}
n /= 10;
}
return flag;
}
public static boolean helper(long arr[], int n, long target) {
int i = 0, start = i + 1, end = n - 1;
while (start < end) {
long val = arr[i] + arr[start] + arr[end];
if (val < target) {
start++;
} else if (val > target) {
end--;
} else {
return true;
}
}
return false;
}
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);
}
public static long smallestDivisor(long n) {
// if divisible by 2
if (n % 2 == 0)
return 2;
// iterate from 3 to sqrt(n)
for (int i = 3; i * i <= n; i += 2) {
if (n % i == 0)
return i;
}
return n;
}
public static boolean isPrime(long n) {
// Corner cases
if (n <= 1)
return false;
if (n <= 3)
return true;
// This is checked so that we can skip
// middle five numbers in below loop
if (n % 2 == 0 || n % 3 == 0)
return false;
for (long i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
static long factorize(long n) {
long ans = 0;
// count the number of times 2 divides
while (!(n % 2 > 0)) {
// equivalent to n=n/2;
n >>= 1;
ans++;
}
if (ans > 0)
ans = 1;
// if 2 divides it
// if (count > 0) {
// System.out.println("2" + " " + count);
// }
// check for all the possible
// numbers that can divide it
for (long i = 3; i <= (long) Math.sqrt(n); i += 2) {
int count = 0;
while (n % i == 0) {
count++;
n = n / i;
}
// if (count > 0) {
// System.out.println(i + " " + count);
// }
ans += count;
}
// if n at the end is a prime number.
if (n > 2) {
ans++;
}
return ans;
}
static int countSetBits(long n) {
int count = 0;
while (n > 0) {
n &= (n - 1);
count++;
}
return count;
}
public static long gcd(long a, long b) {
if (a == 0)
// returns y is x==0
return b;
// calling function that returns GCD
return gcd(b % a, a);
}
static long lcm(long a, long b) {
// returns the LCM
return (a / gcd(a, b)) * b;
}
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 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 | d8bc264b148605f72aa820bcfc89b33d | 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();
while(t-->0){
int n = sc.nextInt();
boolean notPerfect = false;
while(n-->0){
int input = sc.nextInt();
if(Math.sqrt(input) % 1 != 0){
notPerfect = true;
}
}
if(!notPerfect){
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 | 17a60784bdac8dc1c5dde94c62a010fa | 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 | /*----->Hope Can Set You Free<-----*/
import java.util.*;
public class PerfactlyInperfectArray {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt(),cnt=0,sq=0;
int[] arr=new int[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
sq=(int)Math.sqrt(arr[i]);
if((sq*sq)!=arr[i]){
cnt++;
}
}
if(cnt>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 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 | 677cb53ef1e47817a4e834c4d8f63f7c | 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 PerfectlyImperfectArray {
static boolean chk(int[] a) {
for (int i = 0; i < a.length; i++)
if ((int) Math.sqrt(a[i]) != Math.sqrt(a[i]))
return true;
return false;
}
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int[] a = new int[n];
for(int i=0; i<n ;i++)
a[i] = sc.nextInt();
if(chk(a))
pw.println("YES");
else
pw.println("NO");
}
pw.flush();
}
static int gcd(int a, int b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(FileReader r) {
br = new BufferedReader(r);
}
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int[] nextIntArr(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
}
return a;
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public boolean ready() throws IOException {
return br.ready();
}
}
}
| Java | ["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 | 2e9f609d9aa309f7683803102e3c4c7f | 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.StringTokenizer;
public class Main {
BufferedReader in;
PrintWriter out;
Main() {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
}
void close() throws IOException {
in.close();
out.flush();
out.close();
}
public static void main(String[] args) throws IOException {
Main m = new Main();
m.solve();
m.close();
}
void solve() throws IOException {
int t = Integer.parseInt(in.readLine());
while (t > 0) {
t--;
int n = Integer.parseInt(in.readLine());
int[] a = new int[n];
StringTokenizer st = new StringTokenizer(in.readLine());
for (int i = 0; i < n; i++) {
a[i] = Integer.parseInt(st.nextToken());
}
boolean ok = true;
for (int i = 0; i < n; i++) {
double si = Math.sqrt(a[i]);
if (Math.abs(si - Math.round(si)) > 1e-10) {
ok = false;
break;
}
}
if (ok) {
out.append("NO\n");
} else {
out.append("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 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 | 88923ccdf2f958bbc8300dba20596e42 | 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[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-- > 0){
int a = in.nextInt();
int[] arr = new int[a];
boolean b = true;
for (int i = 0; i < a; i++) {
arr[i] = in.nextInt();
}
for (int i = 0; i < a; i++) {
if(((int)(Math.sqrt(arr[i]))*((int)(Math.sqrt(arr[i]))) != arr[i])){
b = false;
break;
}
}
if(b) 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 | e9f6e7e30e4b806dec8dfdeef2c2471a | 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 AAA {
//--------------------------INPUT READER--------------------------------//
static class fs {
public BufferedReader br;
StringTokenizer st = new StringTokenizer("");
public fs() { this(System.in); }
public fs(InputStream is) {
br = new BufferedReader(new InputStreamReader(is));
}
String next() {
while (!st.hasMoreTokens()) {
try { st = new StringTokenizer(br.readLine()); }
catch (IOException e) { e.printStackTrace(); }
}
return st.nextToken();
}
int ni() { return Integer.parseInt(next()); }
long nl() { return Long.parseLong(next()); }
double nd() { return Double.parseDouble(next()); }
String ns() { return next(); }
int[] na(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = ni();
return a;
}
}
//-----------------------------------------------------------------------//
//---------------------------PRINTER-------------------------------------//
static class Printer {
static PrintWriter w;
public Printer() {this(System.out);}
public Printer(OutputStream os) {
w = new PrintWriter(os);
}
public void p(int i) {w.println(i);};
public void p(long l) {w.println(l);};
public void p(double d) {w.println(d);};
public void p(String s) { w.println(s);};
public void pr(int i) {w.println(i);};
public void pr(long l) {w.print(l);};
public void pr(double d) {w.print(d);};
public void pr(String s) { w.print(s);};
public void pl() {w.println();};
public void close() {w.close();};
}
//------------------------------------------------------------------------//
//--------------------------VARIABLES------------------------------------//
static fs sc = new fs();
static OutputStream outputStream = System.out;
static Printer w = new Printer(outputStream);
//-----------------------------------------------------------------------//
//--------------------------ADMIN_MODE-----------------------------------//
private static void ADMIN_MODE() throws IOException {
if (System.getProperty("ONLINE_JUDGE") == null) {
w = new Printer(new FileOutputStream("output.txt"));
sc = new fs(new FileInputStream("input.txt"));
}
}
//-----------------------------------------------------------------------//
//----------------------------START--------------------------------------//
public static void main(String[] args)
throws IOException {
ADMIN_MODE();
int t = sc.ni();
while(t-->0)
solve();
w.close();
}
static void solve() throws IOException {
int n = sc.ni();
int[] arr = sc.na(n);
for(int i = 0; i < n; i++) {
int sqrt = (int)Math.sqrt(arr[i]);
if(sqrt*sqrt != arr[i]) {
w.p("YES");
return;
}
}
w.p("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 | |
PASSED | 004192bee15b47fc0797e84e0f58f8b0 | 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 Perfect
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
boolean flag=false;
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)
flag=true;
}
System.out.println(flag?"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 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 | 14c3f3843d23a59bcf9e928a0912de42 | 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 long startTime = System.currentTimeMillis();
// for global initializations and methods starts here
// global initialisations and methods end here
static void run() {
boolean tc = true;
AdityaFastIO r = new AdityaFastIO();
//FastReader r = new FastReader();
try (OutputStream out = new BufferedOutputStream(System.out)) {
//long startTime = System.currentTimeMillis();
int testcases = tc ? r.ni() : 1;
int tcCounter = 1;
// Hold Here Sparky------------------->>>
// Solution Starts Here
start:
while (testcases-- > 0) {
long n = r.nl();
boolean ff = false;
for (int i = 0; i < n; i++) {
long a = r.nl();
long x = (int)Math.sqrt(a);
ff = ff || x * x != a;
}
out.write((ff ? "YES" : "NO" + " ").getBytes());
out.write(("\n").getBytes());
}
// Solution Ends Here
} catch (IOException e) {
e.printStackTrace();
}
}
static class AdityaFastIO {
final private int BUFFER_SIZE = 1 << 16;
private final DataInputStream din;
private final byte[] buffer;
private int bufferPointer, bytesRead;
public BufferedReader br;
public StringTokenizer st;
public AdityaFastIO() {
br = new BufferedReader(new InputStreamReader(System.in));
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public AdityaFastIO(String file_name) throws IOException {
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String word() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
public String line() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
public String readLine() throws IOException {
byte[] buf = new byte[100000001]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int ni() 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 nl() 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 nd() 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 Exception {
run();
}
static long mod = 998244353;
static long modInv(long base, long e) {
long result = 1;
base %= mod;
while (e > 0) {
if ((e & 1) > 0) result = result * base % mod;
base = base * base % mod;
e >>= 1;
}
return result;
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String word() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
String line() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int ni() {
return Integer.parseInt(word());
}
long nl() {
return Long.parseLong(word());
}
double nd() {
return Double.parseDouble(word());
}
}
static int MOD = (int) (1e9 + 7);
static long powerLL(long x, long n) {
long result = 1;
while (n > 0) {
if (n % 2 == 1) result = result * x % MOD;
n = n / 2;
x = x * x % MOD;
}
return result;
}
static long powerStrings(int i1, int i2) {
String sa = String.valueOf(i1);
String sb = String.valueOf(i2);
long a = 0, b = 0;
for (int i = 0; i < sa.length(); i++) a = (a * 10 + (sa.charAt(i) - '0')) % MOD;
for (int i = 0; i < sb.length(); i++) b = (b * 10 + (sb.charAt(i) - '0')) % (MOD - 1);
return powerLL(a, b);
}
static long gcd(long a, long b) {
if (a == 0) return b;
else return gcd(b % a, a);
}
static long lcm(long a, long b) {
return (a * b) / gcd(a, b);
}
static long lower_bound(List<Long> list, long k) {
int s = 0;
int e = list.size();
while (s != e) {
int mid = (s + e) >> 1;
if (list.get(mid) < k) s = mid + 1;
else e = mid;
}
if (s == list.size()) return -1;
return s;
}
static int upper_bound(List<Long> list, long k) {
int s = 0;
int e = list.size();
while (s != e) {
int mid = (s + e) >> 1;
if (list.get(mid) <= k) s = mid + 1;
else e = mid;
}
if (s == list.size()) return -1;
return s;
}
static void addEdge(ArrayList<ArrayList<Integer>> graph, int edge1, int edge2) {
graph.get(edge1).add(edge2);
graph.get(edge2).add(edge1);
}
public static class Pair implements Comparable<Pair> {
int first;
int second;
public Pair(int first, int second) {
this.first = first;
this.second = second;
}
public String toString() {
return "(" + first + "," + second + ")";
}
public int compareTo(Pair o) {
// TODO Auto-generated method stub
if (this.first != o.first)
return (int) (this.first - o.first);
else return (int) (this.second - o.second);
}
}
public static class PairC<X, Y> implements Comparable<PairC> {
X first;
Y second;
public PairC(X first, Y second) {
this.first = first;
this.second = second;
}
public String toString() {
return "(" + first + "," + second + ")";
}
public int compareTo(PairC o) {
// TODO Auto-generated method stub
return o.compareTo((PairC) first);
}
}
static boolean isCollectionsSorted(List<Long> list) {
if (list.size() == 0 || list.size() == 1) return true;
for (int i = 1; i < list.size(); i++) if (list.get(i) <= list.get(i - 1)) return false;
return true;
}
static boolean isCollectionsSortedReverseOrder(List<Long> list) {
if (list.size() == 0 || list.size() == 1) return true;
for (int i = 1; i < list.size(); i++) if (list.get(i) >= list.get(i - 1)) 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 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 | 6a46535e4c035317ab9a37cbbcc2f195 | 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 java.math.*;
import java.math.BigInteger;
//import javafx.util.*;
public final class B
{
static StringBuilder ans=new StringBuilder();
static FastReader in=new FastReader();
static ArrayList<ArrayList<Integer>> g;
static long mod=1000000007;
static int D1[],D2[],par[];
static boolean set[];
static long INF=Long.MAX_VALUE;
public static void main(String args[])throws IOException
{
int T=i();
outer:while(T-->0)
{
int N=i();
int A[]=input(N);
for(int i=0; i<N; i++)
{
long p=A[i];
if(Math.ceil(Math.sqrt(p))!=Math.floor(Math.sqrt(p)))
{
System.out.println("YES");
continue outer;
}
}
System.out.println("NO");
}
}
static boolean reverse(long A[],int l,int r)
{
while(l<r)
{
long t=A[l];
A[l]=A[r];
A[r]=t;
l++;
r--;
}
if(isSorted(A))return true;
else return false;
}
static boolean isSorted(long A[])
{
for(int i=1; i<A.length; i++)if(A[i]<A[i-1])return false;
return true;
}
static boolean isPalindrome(char X[],int l,int r)
{
while(l<r)
{
if(X[l]!=X[r])return false;
l++; r--;
}
return true;
}
static long min(long a,long b,long c)
{
return Math.min(a, Math.min(c, b));
}
static void print(int a)
{
System.out.println("! "+a);
}
static int ask(int a,int b)
{
System.out.println("? "+a+" "+b);
return i();
}
static int find(int a)
{
if(par[a]<0)return a;
return par[a]=find(par[a]);
}
static void union(int a,int b)
{
a=find(a);
b=find(b);
if(a!=b)
{
par[a]+=par[b]; //transfers the size
par[b]=a; //changes the parent
}
}
static void swap(char A[],int a,int b)
{
char ch=A[a];
A[a]=A[b];
A[b]=ch;
}
static void sort(long[] a) //check for long
{
ArrayList<Long> l=new ArrayList<>();
for (long i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static void setGraph(int N)
{
g=new ArrayList<ArrayList<Integer>>();
for(int i=0; i<=N; i++)
{
g.add(new ArrayList<Integer>());
}
}
static long pow(long a,long b)
{
long mod=1000000007;
long pow=1;
long x=a;
while(b!=0)
{
if((b&1)!=0)pow=(pow*x)%mod;
x=(x*x)%mod;
b/=2;
}
return pow;
}
static long toggleBits(long x)//one's complement || Toggle bits
{
int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;
return ((1<<n)-1)^x;
}
static int countBits(long a)
{
return (int)(Math.log(a)/Math.log(2)+1);
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static boolean isPrime(long N)
{
if (N<=1) return false;
if (N<=3) return true;
if (N%2 == 0 || N%3 == 0) return false;
for (int i=5; i*i<=N; i=i+6)
if (N%i == 0 || N%(i+2) == 0)
return false;
return true;
}
static long GCD(long a,long b)
{
if(b==0)
{
return a;
}
else return GCD(b,a%b );
}
//Debugging Functions Starts
static void print(char A[])
{
for(char c:A)System.out.print(c+" ");
System.out.println();
}
static void print(boolean A[])
{
for(boolean c:A)System.out.print(c+" ");
System.out.println();
}
static void print(int A[])
{
for(int a:A)System.out.print(a+" ");
System.out.println();
}
static void print(long A[])
{
for(long i:A)System.out.print(i+ " ");
System.out.println();
}
static void print(ArrayList<Integer> A)
{
for(int a:A)System.out.print(a+" ");
System.out.println();
}
//Debugging Functions END
//----------------------
//IO FUNCTIONS STARTS
static HashMap<Integer,Integer> Hash(int A[])
{
HashMap<Integer,Integer> mp=new HashMap<>();
for(int a:A)
{
int f=mp.getOrDefault(a,0)+1;
mp.put(a, f);
}
return mp;
}
static int i()
{
return in.nextInt();
}
static long l()
{
return in.nextLong();
}
static int[] input(int N){
int A[]=new int[N];
for(int i=0; i<N; i++)
{
A[i]=in.nextInt();
}
return A;
}
static long[] inputLong(int N) {
long A[]=new long[N];
for(int i=0; i<A.length; i++)A[i]=in.nextLong();
return A;
}
//IO FUNCTIONS END
}
//class pair implements Comparable<pair>{
// int index; long a;
// pair(long a,int index)
// {
// this.a=a;
// this.index=index;
// }
// public int compareTo(pair X)
// {
// if(this.a>X.a)return 1;
// if(this.a==X.a)return this.index-X.index;
// return -1;
// }
//}
//Code For FastReader
//Code For FastReader
//Code For FastReader
//Code For FastReader
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());
}
//gey
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 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 | ddb5b7565c54d5a0d2bc9c56dcd20bff | 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 main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
long kk = sc.nextLong();
while(kk-->0) {
int length = sc.nextInt();
int[] arr = new int[length];
boolean flag = true;
for(int i = 0; i < length; i++) {
arr[i] = sc.nextInt();
}
for(int i : arr) {
if(Math.sqrt(i)%1!=0) {
flag=false;
break;
}
}
System.out.println(!flag?"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 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 | 10e614226890a3daf824e9f6ac66a520 | 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 Question4{
public static void main(String args[]){
Scanner In = new Scanner(System.in);
int t = In.nextInt();
while(t>0)
{
int n = In.nextInt();
long a[] = new long[n];
int l = 7;
for(int i=0;i<n;i++) {
a[i] = In.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=1;
}
}
if(l==1) {
System.out.println("YES");
}
else {
System.out.println("NO");
}
t--;
}
In.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 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 | 15318767c68be66aea8b581e1ee619ff | 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.lang.Math;
public class Main{
static boolean isPerfectSquare(double x){
if(x>=0){
long sr = (long) Math.sqrt(x);
return (sr*sr==x);
}
return false;
}
public static void main(String[] args){
Scanner s = new Scanner(System.in);
int T = s.nextInt();
for(int i=0; i<T; i++){
int n = s.nextInt();
boolean br = false;
for(int j=0; j<n;j++){
int x = s.nextInt();
if(!isPerfectSquare(x)){
br = true;
}
}
if(br==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 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 | 923a418922b477aa869cea42ac69cb93 | 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.lang.*;
public class Solution{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int x=0; x<t; x++)
{
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0; i<n; i++)
arr[i]= sc.nextInt();
System.out.println(solve(arr,n));
}
}
public static String solve(int[] arr,int n){
int i=0;
while(i<n){
if(Math.sqrt(arr[i])!= Math.floor(Math.sqrt(arr[i]))) return "YES";
i++;
}
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 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 | 104f0daf6ee52efbe91c2502e3c61323 | 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 | // Piyush Nagpal
import java.util.*;
import java.io.*;
public class C{
static int MOD=1000000007;
static PrintWriter pw;
static FastReader sc;
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());}
public char nextChar() throws IOException {return next().charAt(0);}
String nextLine(){
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
public int[] intArr(int n) throws IOException {
int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
return in;
}
public long[] longArr(int n) throws IOException {
long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
return in;
}
}
public static long gcd(long a,long b){if( b>a ){return gcd(b,a);}if( b==0 ){return a;} return gcd(b,a%b);}
public static ArrayList<Long> Sieve(int n){
boolean [] arr= new boolean[n+1];
Arrays.fill(arr, true);
ArrayList<Long> list= new ArrayList<>();
for(int i=2;i<=n;i++){
if( arr[i]==true ){
list.add((long)i);
}
for(int j=2*i;j<=n;j+=i){
arr[j]=false;
}
}
return list;
}
public static void printarr(int [] arr){
for(int i=0;i<arr.length;i++){
pw.print(arr[i]+" ");
}
}
// int [] arr=sc.intArr(n);
static void solve() throws Exception{
int n=sc.nextInt();
int [] arr= sc.intArr(n);
for(int i=0;i<n;i++){
if( Math.sqrt(arr[i])%1!=0 ){
pw.println( "YES" );
return;
}
}
pw.println("NO");
}
public static void main(String[] args) throws Exception{
try {
System.setIn(new FileInputStream("input.txt"));
System.setOut(new PrintStream(new FileOutputStream("output.txt")));
} catch (Exception e) {
System.err.println("Error");
}
sc= new FastReader();
pw = new PrintWriter(System.out);
int tc=1;
tc=sc.nextInt();
for(int i=1;i<=tc;i++) {
// pw.printf("Case #%d: ", i);
solve();
}
pw.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 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 | da85c9a1563c62edc220e18f93beaf81 | 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 PerfectlyImperfectArray {
public static void main(String args[]){
FScanner in = new FScanner();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
while(t-->0) {
int n=in.nextInt();
int f=0;
for(int i=0;i<n;i++)
{
long a=in.nextLong();
long b=(int)Math.sqrt(a);
if(a!=b*b)
f=1;
}
if(f==1)
out.println("YES");
else
out.println("NO");
}
out.close();
}
static class FScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer sb = new StringTokenizer("");
String next(){
while(!sb.hasMoreTokens()){
try{
sb = new StringTokenizer(br.readLine());
} catch(IOException e){ }
}
return sb.nextToken();
}
String nextLine(){
try{ return br.readLine(); }
catch(IOException e) { } return "";
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
int[] readArray(int n) {
int a[] = new int[n];
for(int i=0;i<n;i++) a[i] = nextInt();
return a;
}
float nextFloat(){
return Float.parseFloat(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
}
}
| Java | ["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 | 687e15f82164eed38faefc429d82e9f8 | 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.PrintWriter;
import java.util.*;
import java.lang.*;
public class Main
{
static int po(int n){
int a=2;
int res=1;
while(n>0){
if(n%2==0){
res*=a;
n--;
}else{
a*=a;
n/=2;
}
}
return res;
}
public static void main(String[] args) {
PrintWriter out1=new PrintWriter(System.out);
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
//sc.nextLine();
while(t-->0){
int n=sc.nextInt();
int[] a=new int[n];
int flag=0;
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}
for(int i=0;i<n;i++){
int p=a[i];
if (Math.ceil((double)Math.sqrt(p)) == Math.floor((double)Math.sqrt(p))) {
continue;
}
else {
flag=1;
break;
}
}
if(flag==1){
out1.println("yes");
}else{
out1.println("no");
}
}
out1.flush();
out1.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 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 |
Subsets and Splits