Problem Description
On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make.
Input
The input file consists of several test cases. Each case the first line is a numbers N (N <= 500). The next N lines ,each line contain two number Xi and Yi(-100 <= xi,yi <= 100), means the points’ position.(the data assures no two points share the same position.)
Output
For each case, output a number means how many different regular polygon these points can make.
Sample Input
4 0 0 0 1 1 0 1 1 6 0 0 0 1 1 0 1 1 2 0 2 1
Sample Output
1 2
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner reader=new Scanner(System.in);
while(reader.hasNext()){
int a=reader.nextInt();
ArrayList<A> l=new ArrayList<A>();
//int s[][]=new int[505][505];
int map[][]=new int[300][300];
for(int n=0;n<a;n++){
int x=reader.nextInt();
int y=reader.nextInt();
x+=100;
y+=100;
//System.out.println(x+" "+y);
A aa=new A(x,y);
l.add(aa);
map[x][y]=1;
}
int sum=0;
for(int n1=0;n1<a-1;n1++){
for(int n2=n1+1;n2<a;n2++){
int x1=l.get(n1).x;
int y1=l.get(n1).y;
int x2=l.get(n2).x;
int y2=l.get(n2).y;
int xx=x1-x2;
int yy=y1-y2;
//System.out.println(xx+" "+yy+" "+x1+" "+y1+" "+x2+" "+y2+" "+(x1+yy)+" "+(y1-xx)+" "+(x2+yy)+" "+(y2-xx));
if(x2+yy>=0&&x2+yy<=205&&y2-xx>=0&&y2-xx<=205&&x1+yy>=0&&x1+yy<=205&&y1-xx>=0&&y1-xx<=205&&map[x1+yy][y1-xx]==1&&map[x2+yy][y2-xx]==1){
sum++;
//System.out.println(sum);
}
if(x2-yy>=0&&x2-yy<=205&&y2+xx>=0&&y2+xx<=205&&x1-yy>=0&&x1-yy<=205&&y1+xx>=0&&y1+xx<=205&&map[x1-yy][y1+xx]==1&&map[x2-yy][y2+xx]==1){
sum++;
//System.out.println(sum);
}
}
}
System.out.println(sum/4);
}
}
}
class A{
int x,y;
A(int a,int b){
x=a;y=b;
}
}