-
Notifications
You must be signed in to change notification settings - Fork 3
/
Finding_Numbers.java
62 lines (53 loc) · 990 Bytes
/
Finding_Numbers.java
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.geek;
import java.util.Arrays;
import java.util.Scanner;
public class Finding_Numbers {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0)
{
int n=sc.nextInt();
int a[]=new int [2*n+2];
for(int i=0;i<2*n+2;i++)
{
a[i]=sc.nextInt();
}
getNumbers(a,a.length);
t--;
}
}
private static void getNumbers(int[] a, int l) {
// TODO Auto-generated method stub
int sum=a[0];
int x=0,y=0,set;
for(int i=1;i<l;i++)
{
sum=sum^a[i];
}
set=sum&~(sum-1);
for(int i=0;i<l;i++)
{
if((a[i] & set)!=0)
x=x^a[i];
else
y=y^a[i];
}
System.out.println(y+" "+x);
// Arrays.sort(a);
// for(int i=1;i<l;)
// {
// if(a[i]==a[i-1])
// {
// i++;
// }
// else
// {
// System.out.print(a[i]+" ");
//// i=i+2;
// i++;
// }
// }
}
}