Cod sursa(job #1732291)

Utilizator antanaAntonia Boca antana Data 21 iulie 2016 13:23:10
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1 kb
#include <cstdio>
#include<unordered_set>
#include<ctype.h>
#define BUF_SIZE 4096
#define MAXN 276997

using namespace std;

unordered_set <long long> v;

int pos=BUF_SIZE;
char buf[BUF_SIZE];

FILE *fin=fopen("dtcsu.in", "r"), *fout=fopen("dtcsu.out", "w");

inline char getChar()
{
    if(pos==BUF_SIZE)
    {
        fread(buf, 1, BUF_SIZE, fin);
        pos=0;
    }
    return buf[pos++];
}
inline long long getNumber()
{
    long long nr=0;
    char c;
    c=getChar();
    while(!isdigit(c))
        c=getChar();
    while(isdigit(c))
        nr=nr*10+c-'0', c=getChar();
    return nr;
}

int main()
{
    long long x, q, nr=0;

    for(int i=1;i<=MAXN;++i)
    {
        x=getNumber();
        if((x&1)) v.insert(x);
    }

    q=getNumber();
    for(int i=1;i<=q;++i)
    {
        x=getNumber();
        if(x)  x/= x & (-x);
        if(x && v.find(x)!=v.end()) nr++;
    }

    fprintf(fout, "%lld", nr);

    fclose(fin);
    fclose(fout);
    return 0;
}