Pagini recente » Cod sursa (job #156698) | Cod sursa (job #1570540) | Cod sursa (job #712977) | Monitorul de evaluare | Cod sursa (job #1282158)
//Deresu Roberto - FMI
//Re :)
#include<fstream>
#include<algorithm>
#define nx 100000
using namespace std;
int n,rez;
struct punct
{
int x,y;
}a[1007];
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
int cmp(punct a, punct b)
{
if(a.x < b.x || (a.x == b.x && a.y < b.y)) return 1;
return 0;
}
int cauta(int x, int y)
{
int poz, pas;
poz = 1;
pas = 1<<10;
while(pas>>=1)
if(poz+pas <= n && (a[poz+pas].x <= x || (a[poz+pas].x == x && a[poz+pas].y <= y)))
poz += pas;
if(a[poz].x == x && a[poz].y == y) return 1;
return 0;
}
int numar()
{
double y;
fin>>y;
y *= nx;
int x = y;
if(x >= 0)
{
if(x%10 == 9) x = x/10+1;
else x = x/10;
}
else
{
if(-x%10 == 9) x = x/10-1;
else x = x/10;
}
return 2*x;
}
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
{
a[i].x = numar();
a[i].y = numar();
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
{
int x3,y3,x4,y4;
x3 = a[i].x+a[i].y-a[j].y;
y3 = a[i].y+a[j].x-a[i].x;
x4 = a[i].y+a[j].x-a[j].y;
y4 = a[j].x+a[j].y-a[i].x;
if(cauta(x3,y3) && cauta(x4,y4)) rez++;
}
fout<<rez/2;
return 0;
}