Cod sursa(job #1828586)

Utilizator c0mradec0mrade c0mrade Data 13 decembrie 2016 16:52:51
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#include<bits/stdc++.h>
using namespace std;
ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");

const int BMax=1<<10;
int pos=1023;
char Buffer[BMax];

inline void read(long long &x){
    while(!isdigit(Buffer[pos]))
        if(++pos == BMax)
        {
            fin.read(Buffer, BMax);
            pos = 0;
        }
    x=0LL;
    while(isdigit(Buffer[pos]))
    {
        x=x*10LL+(Buffer[pos]-'0');
        if(++pos==BMax)
        {
            fin.read(Buffer, BMax);
            pos = 0;
        }
    }
}

unordered_set<long long> s;
const int N = 276997;
long long x, q, ans;

int main() {
    for(int i=1; i<=N; ++i) {
        read(x);
        if((x&1)) s.insert(x);
    }

    read(q);
    for(int i=1; i<=q; ++i) {
        read(x);
        if(x)  x/= x & (-x);
        if(x & s.find(x) != s.end())
            ++ans;
    }

    fout << ans << '\n';

    return 0;
}