### square sum

#### Description:

"Everyone knows what a square looks like. Mathematically, a square is a regular quadrilateral. This means that it has four equal sides and four equal angles (90 degree angles). One beautiful day, Johnny eagerly examined the interesting properties of squares. He did not forget you, his best friend and a talented programmer and thus made a problem about squares to challenge your programming ability. The problem is: given a set of N points in the plane, how many squares are there such that all their corners belong to this set? Now let's show Johnny your skill! Input The first line contains t, the number of test cases (about 10). Then t test cases follow. Each test case has the following form: The first line contains an integer N, the number of points in the given set (4 <= N <= 500). Then N lines follow, each line contains two integers X, Y describing coordinates of a point (-50,= X, Y <= 50). Output For each test case, print in a single line the number of squares that have vertices belong to the given set." Test Case 1 Input (stdin) 1 7 0 0 0 1 1 0 1 1 1 2 2 1 2 2 Expected Output 3 Test Case 2 Input (stdin) 1 4 1 1 1 2 2 1 2 2 Expected Output 1

#### Program :

#include <stdio.h>

int main() {

int numcase,I,i,j,n,count,x[500],y[500],point[101][101];

int x1,x2,x3,x4,y1,y2,y3,y4;

scanf("%d",&numcase);

for(I=0;I<numcase;I++) {

scanf("%d",&n);

for(i=0;i<=100;i++)

for(j=0;j<=100;j++) point[i][j]=0;

for(i=0;i<n;i++) {

scanf("%d%d",&x[i],&y[i]);

x[i]+=50;

y[i]+=50;

point[x[i]][y[i]]=1;

}

count=0;

for(i=0;i<n;i++) {

for(j=0;j<n;j++) {

if(i!=j) {

x1=x[i],y1=y[i];

x2=x[j],y2=y[j];

x3=x1+y1-y2;

y3=y1+x2-x1;

x4=x2+y1-y2;

y4=y2+x2-x1;

if((x3>=0)&&(x3<=100)&&(y3>=0)&&(y3<=100)&&(point[x3][y3]==1)&&(x4>=0)&&(x4<=100)&&(y4>=0)&&(y4<=100)&&(point[x4][y4]==1))

count++;

}}}

printf("%d\n",count/4);

}

return 0;

}