-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB1613.java
More file actions
38 lines (36 loc) · 1.08 KB
/
Copy pathB1613.java
File metadata and controls
38 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.*;
public class B1613 {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while (t-- > 0) {
HashSet<Integer> set = new HashSet<>();
int n=scn.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++){
arr[i]=scn.nextInt();
set.add(arr[i]);
}
Arrays.sort(arr);
int count=0;
int max=n/2;
for(int i=0;i<n;i++){
int x = arr[i];
for(int j=i+1;j<n;j++){
int y=arr[j];
int mod;
if(count==max){
break;
}
int big=Math.max(x,y);
int smol=Math.min(x,y);
mod=big%smol;
if(big!=smol && !(set.contains(mod))){
count++;
System.out.println(big+" "+smol);
}
}
}
}
}
}