Cod sursa(job #1497053)

Utilizator StarGold2Emanuel Nrx StarGold2 Data 5 octombrie 2015 23:34:13
Problema Dtcsu Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.94 kb
/*
    Inspired by other well known programmers :D
*/
#include <cstdio>
#include <cstring>
#include <tr1/unordered_set>
#define DIM 276997
using namespace std;

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

tr1::unordered_set <long long> mySet;
int Q, sol, i; long long val; char S[20];

void read(long long &val){
    val = 0;

    scanf("%s", S + 1);

    for(int i = 1; S[i]; i ++)
        val = val * 10 + (S[i] - '0');

    return;
}

int main(){

    for(i = 1; i <= DIM; ++i){
        //scanf("%lld ", &val);
        read(val);

        if( val & 1 )
            mySet.insert(val);
    }

    scanf("%d", &Q);

    for(i = 1; i <= Q; ++i){
        //scanf("%lld", &val);
        read(val);

        if(!val)
            continue;

        val /= (val & (-val));

        if(mySet.count(val))
            sol ++;
    }

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