Pagini recente » Cod sursa (job #2070686) | Cod sursa (job #2061665) | Cod sursa (job #870990) | Cod sursa (job #1273828) | Cod sursa (job #1284434)
#include<fstream>
#include<cstring>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
unordered_map<int,int>mymap;
int n,i,j,k,rez;
const int constanta=10000;
int x[1005],y[1005];
long double vx,vy;
bool ok(int a,int b)
{
unordered_map<int,int> :: iterator it;
it=mymap.find(a);
while (it!=mymap.end() && it->first==a )
{
if (it->second==b) return true;
++it;
}
return false;
}
ifstream f("patrate3.in");
ofstream g("patrate3.out");
int main() //adun 10 000
{
f>>n;
for(i=1;i<=n;i++)
{
f>>vx>>vy;
vx*=constanta;
x[i]=vx+(constanta*10);
vy*=constanta;
y[i]=vy+(constanta*10);
mymap[(int)x[i]]=(int)y[i];
}
for(i=1;i<=n;i++)
for(j=1;j<i;j++)
{
int x1temp=x[i]+y[i]-y[j];
int y1temp=x[j]+y[i]-x[i];
int x2temp=x[j]+y[i]-y[j];
int y2temp=x[j]+y[j]-x[i];
if (ok(x1temp,y1temp) && ok(x2temp,y2temp))
rez++;
}
g<<rez/2<<"\n";
return 0;
}