Cod sursa(job #1495347)

Utilizator StarGold2Emanuel Nrx StarGold2 Data 2 octombrie 2015 22:51:22
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <cstdio>
#include <ctype.h>
#include <unordered_set>
using namespace std;

unordered_set <long long> mySet;

int nr;
long long X, Q;

inline long long citeste(){
    long long x=0;
    char ch = fgetc(fin);
    while(!isdigit(ch)){
        ch = fgetc(fin);
    }
    while(isdigit(ch)){
        x = 10*x+ch-'0';
        ch = fgetc(fin);
    }
    return x;
}

int main(){

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

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

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

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

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

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

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

    fclose(stdin );
    fclose(stdout);

    return 0;
}