Cod sursa(job #1031971)

Utilizator romircea2010FMI Trifan Mircea Mihai romircea2010 Data 15 noiembrie 2013 18:42:07
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.98 kb
#include <cstdio>

using namespace std;

char ch[500000];

inline void Read(long long &x)
{
    x = 0;
    for (int i = 0; ch[i]; ++i)
        x = x*10LL + ch[i] - '0';
}

inline bool Good(long long nr)
{
    if (nr == 0)
        return false;
    while ((nr & 1LL) == 0)
        nr >>= 1LL;
    while (nr % 3LL == 0)
        nr /= 3LL;
    while (nr % 5LL == 0)
        nr /= 5LL;
    while (nr % 7LL == 0)
        nr /= 7LL;
    while (nr % 11LL == 0)
        nr /= 11LL;
    if (nr == 1)
        return true;
    return false;

}

int main()
{
    freopen("dtcsu.in", "r", stdin);
    for (int i = 1; i<=276997; ++i)
        gets(ch);
    gets(ch);

    int ans = 0;
    int Q;
    long long QL;
    long long x;
    Read(QL);
    Q = QL;
    while (Q--)
    {
        gets(ch);
        Read(x);
        if (Good(x))
            ++ans;
    }
    FILE *g = fopen("dtcsu.out", "w");
    fprintf(g, "%d\n", ans);
    fclose(g);
    return 0;
}