Skip to content

Instantly share code, notes, and snippets.

@ilya-murzinov
Created May 16, 2014 19:17
Show Gist options
  • Save ilya-murzinov/5d6010ab362c7388d48c to your computer and use it in GitHub Desktop.
Save ilya-murzinov/5d6010ab362c7388d48c to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class Main2 {
public static String inName = "input.txt";
public static String outName = "output.txt";
public static void main(String[] args) {
try {
String line;
int[][] sides;
String result;
InputStream inputStream = new FileInputStream(inName);
InputStreamReader fileReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(fileReader);
line = bufferedReader.readLine();
sides = new int[Integer.parseInt(line)][3];
for (int i = 0; i < sides.length; i++) {
line = bufferedReader.readLine();
sides[i][0] = Integer.parseInt(line.split(" ")[0]);
sides[i][1] = Integer.parseInt(line.split(" ")[1]);
sides[i][2] = Integer.parseInt(line.split(" ")[2]);
}
Map<Double, Integer> map = new HashMap<Double, Integer>();
for (int[] side : sides) {
double p = (side[0] + side[1] + side[2]) / 2;
double r = Math.sqrt((p - side[0]) * (p - side[1]) * (p - side[2]) / p);
if (!map.containsKey(r)) {
map.put(r, 1);
} else {
map.put(r, map.get(r) + 1);
}
}
int tmp = 0;
for (double i : map.keySet()) {
if (map.get(i) > tmp) {
tmp = map.get(i);
}
}
result = String.valueOf(tmp);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(outName)));
writer.write(result);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment