Cod sursa(job #1065615)

Utilizator dariusdariusMarian Darius dariusdarius Data 23 decembrie 2013 15:14:24
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.88 kb
#include<algorithm>
#include<unordered_set>
using namespace std;
struct MyHash
{
    private: vector<long long> H[6613];
    public:
        inline void insert(long long x) {H[x%6613].push_back(x);}
        inline int count(long long x)
        {
            int h=x%6613;
            for(vector<long long>::iterator it=H[h].begin();it!=H[h].end();it++)
                if(*it==x)
                    return 1;
            return 0;
        }
}S;
int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);
    int N=0,Q;long long x;
    for(int i=1;i<=276997;i++)
    {
        scanf("%lld",&x);
        if(x&1)
            S.insert(x);
    }
    scanf("%d",&Q);
    for(int i=1;i<=Q;i++)
    {
        scanf("%lld",&x);
        while(x%2==0) x>>=1;
        if(S.count(x))
            N++;
    }
    printf("%d\n",N);
    return 0;
}