Pagini recente » Cod sursa (job #809213) | Cod sursa (job #431806) | Cod sursa (job #2863024) | Cod sursa (job #1679365) | Cod sursa (job #1034432)
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int kmod = 131071;
vector<long long> h[kmod + 1];
int key, j;
void add(long long &t){
key = t & kmod;
for(j = 0; j < h[key].size(); ++j)
if(t == h[key][j])
return;
h[key].push_back(t);
}
inline bool isthere(long long &t){
key = t & kmod;
for(j = 0; j < h[key].size(); ++j)
if(t == h[key][j])
return true;
return false;
}
char pars[22];
int p;
inline void nex(long long &t){
p = t = 0;
gets(pars);
while(pars[p] <= '9' && pars[p] >= '0'){
t = t * 10 + pars[p] - '0';
++p;
}
}
int main(){
freopen("dtcsu.in", "r", stdin);
freopen("dtcsu.out", "w", stdout);
long long t;
for(int i = 1; i <= 276997; ++i){
nex(t);
t /= (t & -t);
while(t % 3 == 0)
t /= 3;
add(t);
}
long long q;
int ans = 0;
nex(q);
for(int i = 1; i <= q; ++i){
nex(t);
if(t){
t /= (t & -t);
while(t % 3 == 0)
t /= 3;
if(isthere(t))
++ans;
}
}
printf("%d", ans);
return 0;
}