Pagini recente » Cod sursa (job #1626310) | Cod sursa (job #398415) | Cod sursa (job #210702) | Cod sursa (job #1112083) | Cod sursa (job #1316634)
#include <iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<cmath>
#define mod 666013
#define Nmax 1001
#define k 10000
using namespace std;
int n,sol;
double x,y;
vector <int> hash[mod];
struct punct
{
int x,y;
};
punct puncte[Nmax];
punct rotatie(punct X,punct Y)
{
X.x-=Y.x;
X.y-=Y.y;
int aux;
aux=X.x;
X.x=X.y;
X.y=aux;
X.x=-X.x;
X.x+=Y.x;
X.y+=Y.y;
return X;
}
int find(punct A)
{
int code=1LL*A.x*A.y%mod;
if(code<0)
code+=mod;
int lg=hash[code].size();
for(int i=0;i<lg;++i)
{
if(A.x == puncte[hash[code][i]].x && A.y==puncte[hash[code][i]].y)
return 1;
}
return 0;
}
void frac(int &val)
{
if(val>=0)
{
if(val%10==9)
val=val/10+1;
else
val/=10;
}
else
{
if(-val%10==9)
val=val/10-1;
else
val/=10;
}
}
void citire()
{
int i;
ifstream fin("patrate3.in");
fin>>n;
for(i=1;i<=n;++i)
{
fin>>x>>y;
x*=100000;
y*=100000;
puncte[i].x=x;
puncte[i].y=y;
frac(puncte[i].x);
frac(puncte[i].y);
int code=1LL * puncte[i].x*puncte[i].y % mod;
if(code<0)
code+=mod;
hash[code].push_back(i);
}
}
void solve()
{
int i,j;
punct mij,p1,p2;
for(i=1;i<n;++i)
{
for(j=i+1;j<=n;++j)
{
mij.x=(puncte[i].x + puncte[j].x)/2;
mij.y=(puncte[i].y + puncte[j].y)/2;
p1=rotatie(puncte[i], mij);
p2=rotatie(puncte[j],mij);
if(find(p1) && find(p2))
sol++;
}
}
ofstream fout("patrate3.out");
fout<<sol/2<<"\n";
fout.close();
}
int main()
{
citire();
solve();
return 0;
}