Cod sursa(job #1495350)

Utilizator StarGold2Emanuel Nrx StarGold2 Data 2 octombrie 2015 22:53:19
Problema Dtcsu Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <cstdio>
#include <tr1/unordered_set> // chiar nu stiam ca exista chestia asta
using namespace std;

tr1::unordered_set <long long> mySet;

int Q, nr;
long long X;

int main(){

    freopen("dtcsu.in" ,"r", stdin );
    freopen("dtcsu.out","w", stdout);

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

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

    scanf("%d", &Q);
    for(int i = 1; i <= Q; i ++){
        scanf("%lld", &X);

        if(!(X&1) && (X&(-X)))
            X /= (X&(-X));

        if(mySet.count(X))
            nr ++;
    }

    printf("%d\n", nr);

    fclose(stdin );
    fclose(stdout);

    return 0;
}