Cod sursa(job #1028994)

Utilizator klamathixMihai Calancea klamathix Data 14 noiembrie 2013 21:43:28
Problema Dtcsu Scor Ascuns
Compilator cpp Status done
Runda Marime 0.89 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);
        while (X%3==0) X/=3;
        while (X%5==0) X/=5;
        while (X%7==0) X/=7;
        while (X%11==0) X/=11;
        if (X == 1) ++total;
    }
    printf("%d\n", total);
     
    return 0;
}