Cod sursa(job #1032438)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 15 noiembrie 2013 19:27:39
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda FMI No Stress 4 Marime 1.02 kb
#include<fstream>
#include<algorithm>
#include<string>
using namespace std;
int i,q,sol,l;
long long x,a[7];
string s;

bool este (long long x) {
     for (int i=1; i<=5; ++i) 
      if (x>1) {
               long long aux=a[i];
               long long pow=aux,pp=aux;
               while (x%pow==0) {
                pp=pow;
                if (pow*pow<x&&x%(pow*pow)==0) pow*=pow; else pow*=aux;
                }
               x/=pp;
               }
      if (x==1) return(1); else return(0);
} 

long long citeste(){
     long long rez=0;
     while (s[l]!='\n') { rez=rez*10+int(s[l])-48; ++l; }
     ++l;
     return (rez);
}

int main(void) {
     ifstream fin("dtcsu.in");
     ofstream fout("dtcsu.out");
     getline(fin,s,char(EOF)); s+='\n'; l=0;
     //for (i=1; i<=276997; ++i) x=citeste();
       a[1]=2; a[2]=3; a[3]=5; a[4]=7; a[5]=11;    
     q=citeste();
     for (i=1; i<=q; ++i) {
           x=citeste();
           if ( este(x) ) ++sol;
           }
   fout<<sol;
 return(0);
}