1082 射击比赛 (20分)
一、题目:
二、解析:
AC代码:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
Reader.init(System.in);
int N = Reader.nextInt();
String champion = "", noob = "";
double min = 999999.0, max = 0.0;
for (int i = 0; i < N ; i++) {
String name = Reader.next();
int x = Reader.nextInt();
int y = Reader.nextInt();
double distance = Math.sqrt(x*x+y*y);
if (distance < min) {
min = distance;
champion = name;
}
if (distance > max) {
max = distance;
noob = name;
}
}
System.out.print(champion+" "+noob);
}
}
class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
static void init(InputStream input) {
reader = new BufferedReader(new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
static String next() throws IOException {
while ( ! tokenizer.hasMoreTokens() ) {
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt() throws IOException {
return Integer.parseInt( next() );
}
static double nextDouble() throws IOException {
return Double.parseDouble( next() );
}
}