Cod sursa(job #1030261)

Utilizator Paula-ElenaPaula-Elena Margarit Paula-Elena Data 15 noiembrie 2013 16:04:49
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.73 kb
#include <fstream>
#include <cstring>
using namespace std;

ifstream fin ("dtcsu.in");
ofstream fout ("dtcsu.out");

const int MAXN = 276997;

int N, Q, sol;
unsigned long long v[6] = {0, 2, 3, 5, 7, 11};
char s[70];

inline bool numar (unsigned long long aux)
{
    for (int i=1; i<6; ++i)
        while (aux % v[i] == 0)
            aux/= v[i];

    if (aux == 1)
        return true;
    return false;
}

int main ()
{
    for (int i=0; i<MAXN; ++i)
        fin.getline (s, 70);

    fin >> Q;
    for (int i=0; i<Q; ++i)
    {
        unsigned long long aux;
        fin >> aux;
        if ( numar(aux) )
            ++sol;
    }

    fout << sol;

    fin.close ();
    fout.close ();

    return 0;
}