Pagini recente » Cod sursa (job #1229479) | Cod sursa (job #422050) | Cod sursa (job #2461695) | Cod sursa (job #2709428) | Cod sursa (job #1031230)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LMAX 1000
char stmp[LMAX];
int nread, poz, L;
void ReadInt(int& x) {
while (1) {
while (poz < L && (stmp[poz] < '0' || stmp[poz] > '9'))
poz++;
if (poz < L)
break;
fgets(stmp, LMAX - 2, stdin);
L = strlen(stmp);
poz = 0;
}
x = nread = 0;
while (poz < L && stmp[poz] >= '0' && stmp[poz] <= '9') {
x = x * 10 + stmp[poz] - '0';
poz++;
nread++;
}
if (nread == 0)
exit(1);
}
void ReadLongLong(long long& x) {
while (1) {
while (poz < L && (stmp[poz] < '0' || stmp[poz] > '9'))
poz++;
if (poz < L)
break;
fgets(stmp, LMAX - 2, stdin);
L = strlen(stmp);
poz = 0;
}
x = nread = 0;
while (poz < L && stmp[poz] >= '0' && stmp[poz] <= '9') {
x = x * 10 + stmp[poz] - '0';
poz++;
nread++;
}
if (nread == 0)
exit(1);
}
int v[5] = {2, 3, 5, 7, 11};
#define NMAX 276997
long long N;
int i, Q, ans;
int main() {
freopen("dtcsu.in", "r", stdin);
freopen("dtcsu.out", "w", stdout);
poz = L = 0;
for (i = 0; i < NMAX; i++)
ReadLongLong(N);
ReadInt(Q);
ans = 0;
while (Q--) {
ReadLongLong(N);
for (i = 0; i < 5; i++)
while ((N % v[i]) == 0)
N /= v[i];
if (N == 1)
ans++;
}
printf("%d\n", ans);
return 0;
}