Cod sursa(job #1050050)

Utilizator brainwashed20Alexandru Gherghe brainwashed20 Data 8 decembrie 2013 02:19:47
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include<cstdio>
#include<vector>

using namespace std;

const int dim = 5000;

vector<long long> h[dim];
int n = 276997;
long long ans;

int find(int val) {

    int key = val % dim;

    for(auto it  = h[key].begin(); it!=h[key].end(); ++it)
        if(*it == val)
            return 1;

    return 0;
}

int main() {

    freopen("dtcsu.in", "r", stdin);
    freopen("dtcsu.out", "w", stdout);

    long long val;

    while(n--) {
        scanf("%lld",&val);
        if(val % 2 == 1)
            h[val % dim].push_back(val);
    }

    scanf("%d",&n);
    while(n--) {
        scanf("%lld",&val);
        val /= (val & -val);
        ans += find(val);
    }

    printf("%lld\n",ans);

    return 0;
}