Cod sursa(job #518511)
| Utilizator | Data | 1 ianuarie 2011 16:13:16 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <cstdio>
using namespace std;
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int p,x,y=5,t=0;
bool nicht=false;
scanf ("%d",&p);
x=5*p;
while (y<p)
{
y+=6;
t++;
if (p==y)
nicht=true;
}
y=5;
while (y<x)
{
y*=5;
t++;
}
t-=2;
t*=5;
x-=t;
if (nicht==false)
printf ("%d \n",x);
else
printf ("-1 \n");
}