Cod sursa(job #306983)

Utilizator GulosSerban Petrescu Gulos Data 22 aprilie 2009 17:11:57
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.31 kb
#include<iostream>
#include<fstream>

using namespace std;

int main(){
int n,p,m;
	ifstream fin("fact.in");
	fin>>p;
	ofstream fout("fact.out");
	if (p==1)
		fout<<"0";
	else{
		n=5;
		m=306525781;
		while (m>5){
			p-=(p/m);
			m=(m-1)/5;
		}
		fout<<p*5;
	}
	fout.close();
	return 0;
}