Cod sursa(job #1954590)

Utilizator alexpetrescuAlexandru Petrescu alexpetrescu Data 5 aprilie 2017 15:24:48
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.03 kb
#include <cstdio>
#include <cctype>
#include <vector>

#define ll long long

#define BUF_SIZE 1<<17

#define C 276997

#define MOD 9973

std::vector <ll> v[MOD];

int pos=BUF_SIZE;
char buf[BUF_SIZE];
FILE *fin;

inline char nextch(){
    if(pos==BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos=0;
    return buf[pos++];
}

inline ll read(){
    ll x=0;
    char ch=nextch();
    while(!isdigit(ch)) ch=nextch();
    while(isdigit(ch)){
        x=10*x+ch-'0';
        ch=nextch();
    }
    return x;
}

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

    for(int i=0; i<C; i++){
        ll x=read();
        if(x%2) v[x%MOD].push_back(x);
    }

    int ans=0;
    for(int q=read(); q; q--){
        ll x=read();
        if(x!=0) x/=x&(-x);
        int i=0, r=x%MOD;
        while((i<(int)v[r].size())&&(v[r][i]!=x)) i++;
        ans+=(i<(int)v[r].size());
    }

    fprintf(fout, "%d\n", ans);

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