Cod sursa(job #1849998)

Utilizator wilson182Alexandrina Panfil wilson182 Data 18 ianuarie 2017 00:48:22
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#include<stdio.h>
#include<vector>
#define M 12289
using namespace std;
vector <long long> h[13000];
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();
}
int main(){
	freopen("dtcsu.in", "r", stdin);
	freopen("dtcsu.out", "w", stdout);
	long long i, n, x;
	for(i=1;i<=276997;i++){
	scanf("%d", &x);
	if(x % 2) h[x % M].push_back(x);
	}
	int r=0;
	scanf("%d", &n);
	for(i=1;i<=n;i++){
		scanf("%d", &x);
		while(x % 2 == 0) x/=2;
		if (find_value(x) != h[x % M].end()) ++r;
	}
	printf("%d", r);
	return 0;
}