Pagini recente » Cod sursa (job #706070) | Cod sursa (job #1793432) | Cod sursa (job #729096) | Istoria paginii runda/greseli_destepte2 | Cod sursa (job #1954579)
#include <cstdio>
#include <cctype>
#define ll long long
#define BUF_SIZE 1<<17
#define C 276997
#define K 5
int p[K]={99991, 99989, 99971, 99961, 99929};
bool ok[K][100000];
int pos=BUF_SIZE;
char buf[BUF_SIZE];
FILE *fin;
inline char nextch(){
if(pos==BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos=0;
return buf[pos++];
}
inline ll read(){
ll x=0;
char ch=nextch();
while(!isdigit(ch)) ch=nextch();
while(isdigit(ch)){
x=10*x+ch-'0';
ch=nextch();
}
return x;
}
int main(){
FILE *fout;
fin=fopen("dtcsu.in", "r");
fout=fopen("dtcsu.out", "w");
for(int i=0; i<C; i++){
ll x=read();
if(x%2)
for(int j=0; j<K; j++)
ok[j][x%p[j]]=1;
}
int ans=0;
for(int q=read(); q; q--){
ll x=read();
if(x!=0){
x/=x&(-x);
bool rez=1;
for(int j=0; j<K; j++)
rez&=ok[j][x%p[j]];
if(rez){
while(x%3==0) x/=3;
while(x%5==0) x/=5;
while(x%7==0) x/=7;
while(x%11==0) x/=11;
if(x!=1) rez=0;
}
ans+=rez;
}
}
fprintf(fout, "%d\n", ans);
fclose(fin);
fclose(fout);
return 0;
}