Cod sursa(job #2034847)

Utilizator andreicoman299Coman Andrei andreicoman299 Data 8 octombrie 2017 15:14:47
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.17 kb
#include <bits/stdc++.h>

#define zeros(x) (x & (-x))

#define BUF_SIZE 1 << 14
char buf[BUF_SIZE];
int pbuf=BUF_SIZE;
FILE*fi,*fo;
inline char nextch(){
    if(pbuf==BUF_SIZE){
        fread(buf, BUF_SIZE, 1, fi);
        pbuf=0;
    }
    return buf[pbuf++];
}
inline long long nextnum(){
    long long a = 0;
    char c = nextch();
    while(!isdigit(c))
        c = nextch();
    while(isdigit(c)){
        a = a*10 + c - '0';
        c = nextch();
    }
    return a;
}

#define MOD 10007
#define BANANE 276997

std::vector <long long> v[MOD];
int main(){
    fi = fopen("dtcsu.in","r");
    fo = fopen("dtcsu.out","w");

    for(int i = 0; i < BANANE; i++){
        long long x = nextnum();
        if(x % 2 == 1) v[x % MOD].push_back(x);
    }
    int q = nextnum();
    int con = 0;
    for(int i = 1; i <= q; i++){
        long long bruh = nextnum();
        bruh = bruh / (zeros(bruh));
        int ind = 0;
        long long c = bruh % MOD;
        while(ind < v[c].size() && v[c][ind] != bruh) ind++;
        if(ind != v[c].size())
            con++;
    }
    fprintf(fo,"%d", con);
    fclose(fi);
    fclose(fo);
    return 0;
}