Pagini recente » Cod sursa (job #1965055) | Cod sursa (job #3167182) | Cod sursa (job #3243612) | Cod sursa (job #1820010) | Cod sursa (job #1044522)
#include <fstream>
#include <bitset>
#include <cstdio>
using namespace std;
FILE *fin=fopen("dtcsu.in", "r");
FILE *fout=fopen("dtcsu.out", "w");
const int maxb=200000;
int ptr=0;
char buff[maxb];
long long GetLong ()
{
long long nr=0;
while (buff[ptr]<'0' || buff[ptr]>'9')
if ((++ptr)>=maxb)
{
ptr=0;
fread(buff, 1, maxb, fin);
}
while (buff[ptr]>='0' && buff[ptr]<='9')
{
nr=nr*10+buff[ptr]-'0';
if ((++ptr)>=maxb)
{
ptr=0;
fread(buff, 1, maxb, fin);
}
}
return nr;
}
const int Mod[5]={666013, 1000003, 826663, 797593, 959473};
int Val[5]={15, 3, 5, 7, 11};
int N=276997, Q, ANS;
long long X;
bitset<1000010> V[5];
void Add ()
{
for (int i=0; i<5; i++)
V[i][X%Mod[i]]=1;
}
bool Query ()
{
for (int i=0; i<5; i++)
if (!V[i][X%Mod[i]])
return 0;
return 1;
}
int main ()
{
for (int i=1; i<=N; i++)
{
X=GetLong();
Add();
}
Q=GetLong();
int P, U, M, Pos;
for (int q=1; q<=Q; q++)
{
X=GetLong();
if (Query())
{
X/=X&(-X);
for (int i=0; i<5 && X>1; i++)
{
while (X==(X/Val[i])*Val[i])
X/=Val[i];
}
if (X<=1)
ANS++;
}
}
fprintf(fout, "%d\n", ANS);
fclose(fin);
fclose(fout);
return 0;
}