Cod sursa(job #2307665)

Utilizator ionanghelinaIonut Anghelina ionanghelina Data 25 decembrie 2018 13:03:32
Problema Dtcsu Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.09 kb
#include<bits/stdc++.h>
using namespace std;

unordered_set<long long> h;
long long x;
long long q,sol;

const int dim=1000000;
char buff[dim+5];
int pos=0;
 void read(long long &n)
{
    n=0;
    long long sign=1LL;
    while(buff[pos]<'0' || buff[pos]>'9')
    {
        if(buff[pos]=='-') sign=-1LL;
        pos++;
        if(pos==dim)
        {
            pos=0;
            fread(buff,1,dim,stdin);
        }
    }
    while(buff[pos]>='0' && buff[pos]<='9')
    {
        n=n*10LL+buff[pos]-'0';
        pos++;
        if(pos==dim)
        {
            pos=0;
            fread(buff,1,dim,stdin);
        }
    }
    n*=sign;
}
int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);

    fread(buff,1,dim,stdin);

    for(int i=1;i<=276997;i++)
    {
    //    scanf("%lld",&x);

        read(x);
        h.insert(x/((x&(-x))));
    }

    read(q);
    while(q--)
    {
        read(x);
        if(x<=0) continue;
        if(h.find(x/(x&(-x)))!=h.end()) sol+=1LL;
    }

    printf("%lld\n",sol);
    return 0;
}