Cod sursa(job #1031049)

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

bool este (long long x) {
     for (int i=1; i<=5; ++i) 
      if (x>1) {
               long long aux=a[i];
               long long pow=1,pp=1;
               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(0); else return(1);
}    

int main(void) {
     ifstream fin("dtcsu.in");
     ofstream fout("dtcsu.out");
     for (i=1; i<=276997; ++i) fin>>x;
       a[1]=2; a[2]=3; a[3]=5; a[4]=7; a[5]=11;    
     fin>>q;
     for (i=1; i<=q; ++i) {
           fin>>x;
           if ( este(x) ) ++sol;
           }
   fout<<sol;
 return(0);
}