Skip to content

Instantly share code, notes, and snippets.

@MukulLatiyan
Created October 22, 2017 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MukulLatiyan/be89922b6d8e1cac80f26cce60819090 to your computer and use it in GitHub Desktop.
Save MukulLatiyan/be89922b6d8e1cac80f26cce60819090 to your computer and use it in GitHub Desktop.
Equal to product(GeeksForGeeks)
//Java code for eual to product problem given on geeksforgeeks array school section.
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG {
public static void main (String[] args) {
Scanner scan = new Scanner(System.in);
int ntest = scan.nextInt();
outer:
while (ntest-- > 0){
int size = scan.nextInt(), mult = scan.nextInt();
int arr[] = new int[size];
for (int i = 0; i < size; i++){
arr[i] = scan.nextInt();
}
Arrays.sort(arr);
for (int i = 0; i < size; i++){
if (arr[i] > mult){
break;
}
if (arr[i] == 0 || mult % arr[i] != 0){
continue;
}
if (Arrays.binarySearch(arr, mult / arr[i]) >= 0){
System.out.println("Yes");
continue outer;
}
}
System.out.println("No");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment