Pagini recente » Cod sursa (job #1640584) | Cod sursa (job #302942) | Cod sursa (job #303072) | Cod sursa (job #2686520) | Cod sursa (job #1044530)
#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];
int main ()
{
fread(buff, 1, maxb, fin);
for(int i=1; i<=276997; i++)
{
long long X=GetLong();
for(int j=0; j<5; j++)
V[j][X%Mod[j]]=1;
}
Q=GetLong();
for(; Q; Q--)
{
X=GetLong();
bool OK=1;
for(int j=0; j<5 && OK; j++)
if(V[j][X%Mod[j]] == 0)
OK=0;
if(OK)
{
X/=(X&(-X));
for(; (X/15)*15 == X; X/=15);
for(; (X/3)*3 == X; X/=3);
for(; (X/5)*5 == X; X/=5);
for(; (X/7)*7 == X; X/=7);
for(; (X/11)*11 == X; X/=11);
if(X == 1) ANS++;
}
}
fprintf(fout, "%d\n", ANS);
fclose(fin);
fclose(fout);
return 0;
}