import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
public class Main {
public static void main
(String[] args
) { while ((input = br.readLine()) != null) {
if (input.equalsIgnoreCase("exit"))
return;
long startNano
= System.
nanoTime(); brute(input);
long endNano
= System.
nanoTime(); long diff = endNano - startNano;
long diffMilli = diff / 1000000;
System.
out.
println("Time: " + diffMilli
+ " ms"); }
e.printStackTrace();
}
}
/**
* Method inputs all integers into a hashset, and then sums two integers
* and checks for the negation in the set.
* @param input
*/
private static void brute
(String input
) { List<Triplet> list = new ArrayList<Triplet>();
String[] nums
= input.
split("\\s"); int[] array = new int[nums.length];
int index = 0;
HashSet<Integer> set = new HashSet<Integer>();
set.add(num);
array[index] = num;
index++;
}
int i, j, size = array.length;
for (i = 0; i < size - 1; i++) {
for (j = i + 1; j < size; j++) {
if (set.contains(-(array[i] + array[j]))) {
Triplet t = new Triplet(array[i], array[j], -(array[i] + array[j]));
if (list.contains(t)) {
continue;
}
list.add(t);
System.
out.
printf("%d %d %d\n", array
[i
], array
[j
],
-(array
[i
] + array
[j
])); }
}
}
}
public static class Triplet {
private int x, y, z;
public Triplet(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result;
result = prime * result + x;
result = prime * result + y;
result = prime * result + z;
return result;
}
@Override
public boolean equals
(Object obj
) { if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Triplet other = (Triplet) obj;
if (x != other.x)
return false;
if (y != other.y)
return false;
if (z != other.z)
return false;
return true;
}
}
}
CWltcG9ydCBqYXZhLmlvLkJ1ZmZlcmVkUmVhZGVyOwoJaW1wb3J0IGphdmEuaW8uSU9FeGNlcHRpb247CglpbXBvcnQgamF2YS5pby5JbnB1dFN0cmVhbVJlYWRlcjsKCWltcG9ydCBqYXZhLnV0aWwuQXJyYXlMaXN0OwoJaW1wb3J0IGphdmEudXRpbC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