Cod sursa(job #1415410)
Utilizator | Data | 4 aprilie 2015 15:43:44 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int n,p,z,x,a;
cin>>p;
if (p==0)
{
cout<<1;
}
else
{
n=5;
z=1;
while (z<p)
{
n=n+5;
a=n;
x=0;
while (a%5==0)
{
a=a/5;
x++;
}
z=z+x;
}
if (z>p)
{
cout<<-1;
}
else
{
cout<<n;
}
}
}