Cod sursa(job #1848634)

Utilizator wilson182Alexandrina Panfil wilson182 Data 16 ianuarie 2017 13:02:09
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <stdio.h>
#include <vector>
using namespace std;
#define M 12289
vector<long long> h[M];
 
inline vector<long long>::iterator find_value(long long x)
{
    int ord = x % M;
    vector<long long>::iterator it;
 
    for (it = h[ord].begin(); it != h[ord].end(); ++it)
        if (*it == x)
            return it;
    return h[ord].end();
}
 
inline void add(long long x)
{
    int ord = x % M; 
    h[ord].push_back(x);
}

int main()
{
    long long i, y, n, k=0;
     
    freopen("dtcsu.in", "r", stdin);
    freopen("dtcsu.out", "w", stdout);
    int x=276997;
    for(i=1;i<=x;i++){
    	scanf("%d", &y);
    	if(y%2==1)add(y);
	}
 	scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &y);
        if (find_value(y) != h[y % M].end()) ++k;
    }
 	printf("%d", k);
    return 0;
}