Cod sursa(job #6180)

Utilizator skyelHighScore skyel Data 17 ianuarie 2007 22:47:24
Problema Factorial Scor 85
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.29 kb
#include<fstream.h>
#define input "fact.in"
#define output "fact.out"



int main()
	{
	long h,x,n;

	ifstream fin(input);
	ofstream fout(output);
	fin>>n;
	x=n;
	h=1;
	while(h*5+1<=n)
		h=(h*5)+1;
	while(h!=1)
		{
		x-=(x/h);
		h--;
		h=h/5;
		}
	fout<<x*5;
	return 0;
	}