Cod sursa(job #103816)

Utilizator kojocojocaru aurelian kojo Data 15 noiembrie 2007 17:42:38
Problema Numere 2 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include<fstream.h>
ifstream f("numere2.in");
ofstream g("numere2.out");
long  p,i,a[1000000000];
int k,ga;
void eratos(long x)
{
for(long q=2*x;q<=p/2+1;q+=x)
	a[q]=1;
}
int numara(long z)
{int s=0;
while(p%z==0)
	{s++;p/=z;}
return s;
}
int main()
{
f>>p;
for(i=2;i<=(p/2+1)&&!ga;i++)
	if(a[i]==0)
		if(p%i)
			eratos(i);
		else
		{k=numara(i);ga=1;}
		g<<i-1<<'\n'<<k;
return 0;
}