import java.util.Scanner ;
import java.io.BufferedInputStream ;
class Main{
private static Fish[] fish ;
private static double ox,oy ;
private static void Center(double x1,double y1,double x2,double y2){
double x,y ;
double midx,midy ;
x = x2-x1;
y = y2-y1;
midx = (x1+x2)/2.0;
midy = (y1+y2)/2.0;
double dist = distance(midx,midy,x1,y1) ;
double c = Math.sqrt(1.0-dist);
double ang = Math.atan(-x/y);
ox = midx + c*Math.cos(ang);
oy = midy + c*Math.sin(ang);
}
private static double distance(double x1,double y1,double x2,double y2){
double distance = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ;
return distance ;
}
public static void main(String arg[]){
Scanner scan = new Scanner(new BufferedInputStream(System.in)) ;
int T = scan.nextInt() ;
while(T-->0){
int N = scan.nextInt() ;
fish = new Fish[N] ;
for(int i=0;i<N;i++){
fish[i] = new Fish(scan.nextDouble(),scan.nextDouble()) ;
}
int max = 1 ;//这里要注意,在所有匹配点之间的距离都大于2时,至少撒网捞一条鱼,而不可能撒空网
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
int count = 0 ;
if(distance(fish[i].x,fish[i].y,fish[j].x,fish[j].y)>4){
continue ;
}
Center(fish[i].x,fish[i].y,fish[j].x,fish[j].y) ;
for(int k=0;k<N;k++){
if(distance(fish[k].x,fish[k].y,ox,oy)<=1.0001){
count++ ;
}
max = Math.max(max,count) ;
}
}
}
System.out.println(max) ;
}
}
}
class Fish{
double x ;
double y ;
public Fish(double x,double y){
this.x = x ;
this.y = y ;
}
}
hdu1077(Catching fish)(java)
最新推荐文章于 2023-02-09 15:10:42 发布