Cod sursa(job #2003441)

Utilizator pepsiM4A1Ozturk Arif pepsiM4A1 Data 22 iulie 2017 21:42:34
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.98 kb
#include <cstdio>
#include <vector>
#define LL long long
using namespace std;
vector<LL>v[8195];
const int DIM=50000;
int poz=DIM-1;
char buff[DIM];
void citeste(LL &nr)
{
    nr=0;
    while(!('0'<=buff[poz]&&buff[poz]<='9'))
    {
        if(++poz==DIM) fread(buff,1,DIM,stdin),poz=0;
    }
    while('0'<=buff[poz]&&buff[poz]<='9')
    {
        nr=nr*10 + buff[poz]-'0';
        if(++poz==DIM) fread(buff,1,DIM,stdin),poz=0;
    }
}
int main()
{
    freopen ("dtcsu.in","r",stdin);
    freopen ("dtcsu.out","w",stdout);
    LL val;
    for(int i=1;i<=276997;i++)
    {
        citeste(val);
        if(val%2==1) v[val%8191].push_back(val);
    }
    LL q;
    citeste(q);
    int ct=0;
    for(;q>0;--q)
    {
        citeste(val);
        if(val>0) val=val/(val&(-val));
        int ok=0,r=val&8191;
        for(int j=0;j<v[r].size()&&ok==0;j++)
        {
            if(v[r][j]==val) ok=1;
        }
        ct+=ok;
    }
    printf("%d\n",ct);
}