Pagini recente » Cod sursa (job #815061) | Cod sursa (job #2248876) | Cod sursa (job #1263302) | Cod sursa (job #2023609) | Cod sursa (job #1034644)
#include <cstdio>
#include <cstdlib>
#include <bitset>
#include <cstring>
#include <algorithm>
#include <iomanip>
using namespace std;
const int Mod[5] = {666013, 1000003, 826663, 797593, 959473};
int T, Ans;
long long N;
bitset<1000010> Hash[5];
const int MaxB = 100000;
char Buf[MaxB];
int Ptr;
inline long long Get()
{
long long Ans = 0;
while(!isdigit(Buf[Ptr]))
if(++ Ptr >= MaxB)
fread(Buf, 1, MaxB, stdin), Ptr = 0;
while(isdigit(Buf[Ptr]))
{
Ans = Ans * 10 + Buf[Ptr] - '0';
if(++ Ptr >= MaxB)
fread(Buf, 1, MaxB, stdin), Ptr = 0;
}
return Ans;
}
int main()
{
freopen("dtcsu.in", "r", stdin);
freopen("dtcsu.out", "w", stdout);
fread(Buf, 1, MaxB, stdin);
for(int i = 1; i <= 276997; ++ i)
{
long long X = Get();
for(int j = 0; j < 5; ++ j)
Hash[j][X % Mod[j]] = 1;
}
T = Get();
for(; T; T --)
{
N = Get();
bool OK = 1;
for(int j = 0; j < 5 && OK; ++ j)
if(Hash[j][N % Mod[j]] == 0)
OK = 0;
if(OK)
{
N /= (N & (-N));
for(; (N / 15) * 15 == N; N /= 15);
for(; (N / 3) * 3 == N; N /= 3);
for(; (N / 5) * 5 == N; N /= 5);
for(; (N / 7) * 7 == N; N /= 7);
for(; (N / 11) * 11 == N; N /= 11);
if(N == 1) Ans ++;
}
}
printf("%i\n", Ans);
}