Cod sursa(job #1032189)

Utilizator misinozzz zzz misino Data 15 noiembrie 2013 19:02:29
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.98 kb
#include<fstream>
#define D 99999
using namespace std;
int i,q,sol;
long long x;
int poz=D+1;
char buf[100000];
inline long long ianr()
{
    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<=276997;++i)
    fgets(buf,10000,stdin);
    scanf("%d",&q);
    for(i=1;i<=q;++i)
    {
        x=ianr();
        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;
    }
    printf("%d\n",sol);
    return 0;
}