Cod sursa(job #1032485)

Utilizator narcis_vsGemene Narcis - Gabriel narcis_vs Data 15 noiembrie 2013 19:33:22
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda FMI No Stress 4 Marime 1.05 kb
#include<fstream>
#define D 99999
#define Dmax 276997
#define Out "dtcsu.out"
using namespace std;
int i,q,sol;
long long x;
int poz=D+1;
char buf[100000];
inline long long Read()
{
    unsigned long long nr=0;
    while((buf[poz]<'0'||buf[poz]>'9')&&buf[poz]!='-')
    if(++poz>=D)
    fread(buf,D,1,stdin),poz=0;
    int semn=1;
    if(buf[poz]=='-')
    ++poz,semn=-1;
    while('0'<=buf[poz]&&buf[poz]<='9')
    {
        nr=nr*10+buf[poz]-'0';
        if(++poz>=D)
            fread(buf,D,1,stdin),poz=0;
    }

    return nr*semn;
}
int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);
    for(i=1;i<=Dmax;++i)
        fgets(buf,10000,stdin);
    scanf("%d",&q);
    for(i=1;i<=q;++i)
    {
        x=Read();
        while(!(x%2))
        x/=2;
        while(!(x%3))
        x/=3;
        while(!(x%5))
        x/=5;
        while(!(x%7))
        x/=7;
        while(!(x%11))
        x/=11;
        if(x==1)
        ++sol;
    }
    ofstream g(Out);
    g<<sol<<"\n";
    return 0;
}