Cod sursa(job #1033924)

Utilizator raulstoinStoin Raul raulstoin Data 17 noiembrie 2013 16:26:16
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include<fstream>
#include<algorithm>
#include<cstdlib>

#define NMAX 276997
#define LL long long

using namespace std;

ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");

LL v[]={2,3,5,7,11},n,nr;
int q,sol;

const int SZ=10000;
char buffer[SZ+20],*in=buffer;

bool check(char x)
{
	return (x>='0' && x<='9');
}

LL atol()
{
	for(;*in && !check(*in);in++);
	if(*in==0)
	{
		fin.read(buffer,SZ);
		if(check(buffer[SZ-1]))
			for(char c=fin.get(),x=0;check(c);c=fin.get())
				buffer[SZ+(int)x]=c;
		in=buffer;
	}
	for(nr=0LL;check(*in);in++)
		nr=nr*10+(*in-'0');
	return nr;
}

int main()
{
	for(int i=0;i<NMAX;i++)
		n=atol();
	q=atol();
	for(;q;q--)
	{
		n=atol();
		for(int i=0;i<5;i++)
			for(;n%v[i]==0;n/=v[i]);
		sol+=(n==1);
	}
	fout<<sol;
	return 0;
}