Pagini recente » Cod sursa (job #1164878) | Cod sursa (job #2281580) | Cod sursa (job #1722473) | Cod sursa (job #2936359) | Cod sursa (job #1017045)
Utilizator |
Duta Vlad Vman |
Data |
27 octombrie 2013 06:29:35 |
Problema |
Dtcsu |
Scor |
Ascuns |
Compilator |
cpp |
Status |
done |
Runda |
|
Marime |
1.13 kb |
#include <cstdio>
#include <bitset>
using namespace std;
#define ll long long
char B[(4194304>>3)+1];
void set(int a) {
B[a>>3] |= (1<<(a & 7));
}
char test(int a) {
return B[a>>3] & (1<<(a & 7));
}
int main() {
int Q;
register ll X;
const ll F = 4194303LL;
char S[20];
int total = 0;
freopen("dtcsu.in","r", stdin);
freopen("dtcsu.out", "w", stdout);
for (int i=0; i<276997; ++i) {
scanf("%lld", &X);
set((X>>24) & F);
}
scanf("%d\n", &Q);
for (int i=0; i<Q; ++i) {
static int j;
fgets(S,20,stdin);
X = 0LL;
for (j=0; S[j]!='\n'; ++j)
X = X*10+S[j]-'0';
if (X==0LL) continue;
if (!test((X>>24) & F)) {
continue;
}
static ll a;
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;
}