Cod sursa(job #1029847)

Utilizator The_DisturbedBungiu Alexandru The_Disturbed Data 15 noiembrie 2013 15:24:56
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.69 kb
#include<stdio.h>
#include<math.h>
int m,n,i,j,k,nr;
struct point
{
	int x;
	point *y;
}
*h[666013];
inline void intro(int x)
{
	double q=(sqrt(5)-1)/2;
	int y=((int)((double)x*q))%666013;
	point *p=new point;
	p->x=x;
	p->y=h[y];
	h[y]=p;
}
inline bool find(int x)
{
	double q=(sqrt(5)-1)/2;
	int y=((int)((double)x*q))%666013;
	for(point *p=h[y];p!=NULL;p=p->y)
		if(p->x==x)return 1;
	return 0;
}
int main()
{
	freopen("dctsu.in","r",stdin);
	freopen("dctsu.out","w",stdout);
	m=276997;
	for(i=0;i<m;++i)
	{
		scanf("%d",&k);
		intro(k);
	}
	scanf("%d",&n);
	nr=0;
	for(i=0;i<n;++i)
	{
		scanf("%d",&k);
		if(find(k))++nr;
	}
	printf("%d\n",nr);
	return 0;
}