Cod sursa(job #462380)
Utilizator | Data | 10 iunie 2010 17:20:04 | |
---|---|---|---|
Problema | Factorial | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
using namespace std;
#include<cstdio>
unsigned long nr,x;
long p;
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%li",&p);
if (!p) printf("1\n");
while(p>0)
{
nr++;
p--; ;
x=nr;
while(x%5==0) {p--; x=x/5;}
}
if(p==0)
printf("%li\n",nr*5);
else printf("-1\n");
}