Pagini recente » Istoria paginii runda/dasda/clasament | Statistici Catalin Cocis (catalincocis) | Cod sursa (job #2065117) | Cod sursa (job #1921621) | Cod sursa (job #1108092)
#include<fstream>
#include<string>
#include<algorithm>
using namespace std;
const int MOD = 666013;
const int NM = 1002;
typedef struct lnod{
int x,y;
lnod *next;
}*Nod;
typedef struct P{ int x,y; }Point;
Point a[NM];
bool cmp(const Point &a, const Point &b){
if(a.x!=b.x) return (a.x<b.x);
else return (a.y<b.y);
}
string s;
Nod h[MOD];
inline int abs(int x){ return (x<0)?(-x):(x); }
void add(Nod &q,int x,int y){
Nod p = new lnod;
p->x=x;
p->y=y;
p->next=q;
q=p;
}
int main(){
ifstream cin("patrate3.in");
ofstream cout("patrate3.out");
int N,i,j,x,y,l,DX,DY,p1x,p1y,Q,f1,nr=0,semn,tmp;
cin>>N; getline(cin,s);
for(i=1;i<=N;++i)
{
getline(cin,s);
x=y=0; l=s.length();
semn=0;
for(j=0;s[j]!=' ';++j)
if(s[j]!='.')
{
if(s[j]=='-') semn=1;
else x=(x*10)+(s[j]-'0');
}
a[i].x=x * ((semn==1)?(-1):(1));
semn=0;
for(++j; j<l;++j)
if(s[j]!='.')
{
if(s[j]=='-') semn=1;
else y=(y*10)+(s[j]-'0');
}
a[i].y=y * ((semn==1)?(-1):(1));
add(h[abs(x+y)%MOD],x,y);
}
sort(a+1,a+N+1,cmp);
for(i=1;i<N;++i)
for(j=i+1;j<=N;++j)
{
DX=a[i].x-a[j].x; DY=a[i].y-a[j].y;
p1x=a[i].x+DY; p1y=a[i].y-DX;
Q=(abs(p1x+p1y))%MOD;
f1=0;
for(Nod p=h[Q];p;p=p->next)
if(p->x==p1x && p->y==p1y)
{
f1=1;
}
if(f1){
p1x=a[j].x+DY; p1y=a[j].y-DX;
Q=(abs(p1x+p1y))%MOD;
f1=0;
for(Nod p=h[Q];p;p=p->next)
if(p->x==p1x && p->y==p1y)
{
++nr;
break;
}
}
}
nr>>=1;
cout<<nr<<'\n';
return 0;
}