Pagini recente » Cod sursa (job #2976321) | Cod sursa (job #901091) | Cod sursa (job #2557137) | Cod sursa (job #564429) | Cod sursa (job #1802728)
#include<fstream>
#include<bitset>
using namespace std;
ifstream in("dtcsu.in");
ofstream out("dtcsu.out");
int hash_keys[5] = { 666013, 1000003, 826663, 797593, 959473 };
bitset<1000006> bloom_filter [5];
int main()
{
unsigned long long x;
for (int i = 1; i <= 276997; ++i)
{
in >> x;
for (int j = 0; j < 5; ++j)
bloom_filter[j][x%hash_keys[j]] = 1;
}
int Q,nr=0;
in >> Q;
for (int i = 1; i <= Q; ++i)
{
in >> x;
int j;
for (j = 0; j < 5; ++j)
if (bloom_filter[j][x%hash_keys[j]] == 0)
break;
if(x)
x /= x&(-x);
while (x % 3 == 0)
x /= 3;
while (x % 5 == 0)
x /= 5;
while (x % 7 == 0)
x /= 7;
while (x % 11 == 0)
x /= 11;
nr += (x == 1);
}
out << nr;
return 0;
}