Cod sursa(job #175248)

Utilizator f.v.antonFlavius Anton f.v.anton Data 9 aprilie 2008 19:13:52
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream.h>
#include <iostream.h>
#include <math.h>
int main()
{
	long long int p,crt,zerouri=0,i,k;
	fstream f,g;
	f.open("fact.in",ios::in);
	f>>p;
	f.close();
	g.open("fact.out",ios::out);
	crt=2000000000;
	while(zerouri!=p)
	{	zerouri=0;
		k=1;
		while(crt>pow(5,k))
		{
			zerouri+=(crt/(pow(5,k)));
			k++;
		}
	if(zerouri>p)
		crt/=2;
	if(zerouri<p)
		crt+=(crt/2);


	}
	g<<crt;
	g.close();
return 0;}