Cod sursa(job #1029008)

Utilizator klamathixMihai Calancea klamathix Data 14 noiembrie 2013 21:52:59
Problema Dtcsu Scor Ascuns
Compilator cpp Status done
Runda Marime 1.03 kb
#include <cstdio>
 
long long X;
int Q;

char s[32768];
int p = 32767;

template<class T>
void cit(T &x) {
    x = 0;
    while (s[p] < '0' or s[p] > '9') {
        if (++p == 32768) {
            fread(s, 1, 32768, stdin);
            p = 0;
        }
    }

    while (s[p] >='0' and s[p] <= '9') {
        x = x * 10 + s[p] - '0';
        if (++p == 32768) {
            fread(s, 1, 32768, stdin);
            p = 0;
        }
    }
}

int main() {
    freopen("dtcsu.in","r", stdin);
    freopen("dtcsu.out", "w", stdout);
     
    for (int i=0; i<276997; ++i)
        cit(X); 
    cit(Q);
    int total = 0;
    for (int i=0; i<Q; ++i) {
        cit(X);
        if (X == 0) continue;
        X /= (X & -X);
        long long a;
        while ((a = X / 15) * 15 == X) X = a;
        while (((a = X / 3) << 1) + a == X) X = a;
        while (((a = X / 5) << 2) + a == X) X = a;
        while ((a = X /7) * 7 == X) X = a;
        while ((a = X / 11) * 11 == X) X = a;
        total += (X == 1);
    }
    printf("%d\n", total);
     
    return 0;
}