Cod sursa(job #1035059)

Utilizator Dddarius95Darius-Florentin Neatu Dddarius95 Data 18 noiembrie 2013 11:56:46
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.04 kb
#include <fstream>
#include <stdio.h>
#include <algorithm>
#define Nmax 276997
using namespace std;

//ifstream f("dtcsu.in");
//ofstream g("dtcsu.out");

int Q,sol;
long long N,x;

int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);
    for(int i=1;i<=Nmax;++i)scanf("%lld\n",&N);
    //f>>Q;
    scanf("%d\n",&Q);
    for(int i=1;i<=Q;++i)
    {
        long long N;
        //f>>N;
        scanf("%d\n",&N);
        while(N%2==0)N/=2;
        //while(N%3==0)N/=3;
        //while(N%5==0)N/=5;
        //while(N%7==0)N/=7;
        //while(N%11==0)N/=11;
        //if(N==1)++sol;
        bool ok=1;
        for(long long i=3;i*i<=N && ok;i+=2)
        {
            long long j=i;
            while(j%2==0)j/=2;
            while(j%3==0)j/=3;
            while(j%5==0)j/=5;
            while(j%7==0)j/=7;
            while(j%11==0)j/=11;
            if(j>1)ok=0;
        }
        if(ok)++sol;
    }
    printf("%d\n",sol);
    //g<<sol<<'\n';
    //f.close();g.close();
    return 0;
}