import javafx.print.Collation;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;
import java.math.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner s = new Scanner(System.in);
//检测点总数
int num=0;
//居民坐标
int[] People = new int[2];
//获取输入
String[] str = s.nextLine().split(" ");
num = Integer.parseInt(str[0]);
People[0]=Integer.parseInt(str[1]);
People[1] = Integer.parseInt(str[2]);
int[][] arr = new int[num][2];
int index=0;
while (index!=num){
String[] temp = s.nextLine().split(" ");
arr[index][0]= Integer.parseInt(temp[0]);
arr[index][1]= Integer.parseInt(temp[1]);
index++;
}
//创建一个Vector接收各个地方的距离
Vector<Double> Length = new Vector<Double>();
for(int i=0;i<num;i++){
int x = (int) Math.pow((People[0]-arr[i][0]),2);
int y = (int) Math.pow((People[1]-arr[i][1]),2);
double ans = Math.sqrt(x+y);
Length.addElement(ans);
}
//此时获取前三个最近的编号的位置
Vector<Double> Sort = new Vector<Double>();
for(Double i:Length){
Sort.addElement(i);
}
Collections.sort(Sort);
//此时Length的前三个就是要求的 由于序号从1开始 故+1
System.out.println(1+Length.indexOf(Sort.elementAt(0)));
//为了以防重复 每次都将已经判断过的值化成最小值
int local = Length.indexOf(Sort.elementAt(0));
Length.set(local,Double.MIN_VALUE);
System.out.println(1+Length.indexOf(Sort.elementAt(1)));
local = Length.indexOf(Sort.elementAt(1));
Length.set(local,Double.MIN_VALUE);
System.out.println(1+Length.indexOf(Sort.elementAt(2)));
}
}
CCF-CSP 202009-1称检测点查询
最新推荐文章于 2022-03-19 01:19:25 发布