Cod sursa(job #2357574)

Utilizator robertbirsanRobert Birsan robertbirsan Data 27 februarie 2019 15:59:43
Problema Factorial Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.32 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int k,n=-1,a,s,p=0,i;

int main()
{
	f>>p;
	n=5*p;

for (i=25;i<=n;i=i*5)
{
	a=n;
	n=a-5*(a/i);
	n=n+5*(a/i)-5*(n/i);
}
for(int x=5;x<=n;x=x*5)
{
	k=k+n/x;
}
if(p==k)
g<<n;
else
g<<"-1";
	return 0;
}