Cod sursa(job #2015027)

Utilizator Mircea_DonciuDonciu Mircea Mircea_Donciu Data 24 august 2017 21:34:00
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <bits/stdc++.h>
#define pb push_back
#define NMAX 1000005
#define x first
#define y second
#define ll long long
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
FILE* fin=fopen("dtcsu.in","r");
const unsigned maxb=100192;
char buf[maxb];
unsigned ptr=maxb;
inline ll getInt()
{
    ll nr=0;
    while(buf[ptr]<'0'||'9'<buf[ptr])
    if(++ptr>=maxb)
        fread(buf,maxb,1,fin),ptr=0;
    while('0'<=buf[ptr]&&buf[ptr]<='9'){
        nr=nr*10+buf[ptr]-'0';
        if(++ptr>=maxb)
            fread(buf,maxb,1,fin),ptr=0;
    }
    return nr;
}
ofstream fout("dtcsu.out");
unordered_set<ll> mp;
int main()
{
    int i,q,nr=0;
    ll x;
    for(i=1;i<=276997;++i)
    {
        x=getInt();
        while(x && !(x&1)) x>>=1;
        mp.insert(x);
    }
    q=getInt();
    while(q--)
    {
        x=getInt();
        while(x && !(x&1)) x>>=1;
        if(mp.find(x)!=mp.end()) ++nr;
    }
    fout<<nr;
    return 0;
}