Pagini recente » Cod sursa (job #2080348) | Cod sursa (job #2681624) | Cod sursa (job #3249744) | Cod sursa (job #820890) | Cod sursa (job #1038853)
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <iostream>
#include <bitset>
using namespace std;
#define INF (1<<29)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
map<long long, int> m;
#define SIZE 512 * 1024
#define HASH_SIZE (SIZE * 8)
bitset<HASH_SIZE> all;
long long p1_list[] = {0, 86243, 1398269, 3021377, 20996011, 25964951};
long long p2_list[] = {0, 432611, 686049, 2922509, 321534781, 780291637};
int get_hash(long long x, long long k){
return ((x * p1_list[k]) + (k * p2_list[k])) % (HASH_SIZE);
}
int main()
{
freopen("dtcsu.in", "rt", stdin);
freopen("dtcsu.out", "wt", stdout);
for(int i = 0; i < 5; ++i){
long long x;
cin >> x;
m[x] = 1;
int p1 = get_hash(x, 1);
int p2 = get_hash(x, 2);
int p3 = get_hash(x, 3);
all.set(p1);
all.set(p2);
all.set(p3);
}
long long n;
cin >> n;
int ret = 0;
for(int i = 0; i < n; ++i)
{
long long x;
cin >> x;
int p1 = get_hash(x, 1);
int p2 = get_hash(x, 2);
int p3 = get_hash(x, 3);
if(all[p1] && all[p2] && all[p3])
if(m.find(x) != m.end())
++ret;
}
cout << ret;
return 0;
}