Cod sursa(job #1561482)

Utilizator SilviuIIon Silviu SilviuI Data 4 ianuarie 2016 10:26:02
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <stdio.h>
#include <vector>
#define mod 123451

using namespace std;
typedef long long int ll;

int n,nr;
ll x;
vector <ll> uhash[mod+10];

void add_inhash(ll x) { int y=x%mod; uhash[y].push_back(x); }

bool inhash(ll x)
{
	int y=x%mod;
	for (unsigned int i=0;i<uhash[y].size();i++)
	    if (uhash[y][i]==x) return true;
	return false;
}

int main()
{
	freopen("dtcsu.in","r",stdin);
	freopen("dtcsu.out","w",stdout);
	for (int i=1;i<=276997;i++) {
		scanf("%lld",&x); add_inhash(x);
	}
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%lld",&x);
		if (inhash(x)) nr++;
	}
	printf("%d",nr);
	return 0;
}