Pagini recente » Cod sursa (job #296541) | Cod sursa (job #2250811) | Cod sursa (job #256041) | Cod sursa (job #74166) | Cod sursa (job #1033924)
#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;
}