Find pairs with given relation
Submissions: 688   Accuracy:

29.1%

  Difficulty: Easy   Marks: 2

Given an array of distinct integers, write a program to find two pairs (a, b) and (c, d) such that ab = cd, where a, b, c and d are distinct elements.

Input:
First line of input contains a single integer T which denotes the number of test cases. T test cases follows. First line of each test case contains a single integer N which denotes the number of elements in the array. Second line of each test case contains N space separated integers which denotes elements of the array.

Output:
For each test case, print 1 if any such pair is found otherwise print -1.

Constraints:
1<=T<=100
1<=N<=10000

Example:
Input:
2
7
3 4 7 1 2 9 8
6
1 6 3 9 2 10
Output:
1
1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harsh Agarwal
Author: harsh.agarwal0


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.