Cod sursa(job #1329573)
Utilizator | Data | 29 ianuarie 2015 17:29:07 | |
---|---|---|---|
Problema | Factorial | Scor | 45 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <cstdio>
using namespace std;
int p,i,ok,x,k;
int main ()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%d", &p);
if(p==0) printf("1");
else
{
ok=0;
for(i=5;ok<p;i=i+5)
{
k=0;
x=i;
while(x%5==0)
{
x=x/5;
++k;
}
ok=ok+k;
}
i=i-5;
if(ok==p)
printf("%d", i);
else printf("-1");
}
return 0;
}