Pagini recente » Cod sursa (job #2016273) | Cod sursa (job #552684) | Cod sursa (job #431245) | Autentificare | Cod sursa (job #1034779)
#include <cstdio>
#define ll long long
char B[524288];
int main() {
int Q;
ll X;
const ll F = 4194303LL;
char S[20];
int total = 0;
freopen("dtcsu.in","r", stdin);
freopen("dtcsu.out", "w", stdout);
int i;
static int b;
for (i=0; i<276997; ++i) {
scanf("%lld", &X);
b = ((X>>24) & F);
B[b>>3] |= (1<<(b & 7));
}
scanf("%d\n", &Q);
while (Q--) {
static int j;
fgets(S,20,stdin);
X = 0LL;
for (j=0; S[j]!='\n'; ++j)
X = X*10+S[j]-'0';
if (!X) continue;
static ll a;
b = ((X>>24) & F);
if (!(B[b>>3] & (1<<(b & 7)))) continue;
X /= (X&(-X));
while ((a=X/15)*15==X) X = a;
while (((a=X/3)<<1)+a==X) X = a;
while (((a=X/5)<<2)+a==X) X = a;
while ((a=X/7)*7==X) X = a;
while ((a=X/11)*11==X) X = a;
total += (X == 1LL);
}
printf("%d\n", total);
return 0;
}