Cod sursa(job #1260525)

Utilizator mirceadinoMircea Popoveniuc mirceadino Data 11 noiembrie 2014 13:17:08
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.73 kb
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
const string problemName = "dtcsu";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#define DIM 10000
char buff[DIM];
int poz = 0;
void read(lld &numar) {
    numar = 0;
    while (buff[poz] < '0' || buff[poz] > '9')
        if (++poz == DIM)
            fread(buff, 1, DIM, stdin), poz = 0;
    while ('0' <= buff[poz] && buff[poz] <= '9') {
        numar = numar * 1LL * 10 + buff[poz] - '0';
        if (++poz == DIM)
            fread(buff, 1, DIM, stdin), poz = 0;
    }
}

int i;
lld Q, x, sol;
unordered_set<lld> H;

int main() {
#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    for(i = 1; i <= 276997; i++) {
        read(x);
        if(x % 2)
            H.insert(x);
    }

    read(Q);

    while(Q--) {
        read(x);
        if(x) {
            x /= (x & (-x));
            sol += H.count(x);
        }
    }

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

    return 0;
}