Cod sursa(job #1031848)

Utilizator MarghescuGabriel Marghescu Marghescu Data 15 noiembrie 2013 18:30:18
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.64 kb
#include<fstream>
using namespace std;
ifstream f("dtcsu.in");
ofstream g("dtcsu.out");
int descompunere(long long y)
{
    while(y%2==0)
        y/=2;
    while(y%3==0)
        y/=3;
    while(y%5==0)
        y/=5;
    while(y%7==0)
        y/=7;
    while(y%11==0)
        y/=11;
    if(y==1)
        return 1;
    else
        return 0;
}
int main()
{
    long long x;
    for(int i=1;i<=276997;i++)
    {
        f>>x;
    }
    int k,count=0;
    f>>k;
    for(int i=1;i<=k;i++)
    {
        f>>x;
        if(descompunere(x))
            count++;
    }
    g<<count;
    f.close();
    g.close();
    return 0;
}