Mai intai trebuie sa te autentifici.
Cod sursa(job #137130)
| Utilizator | Data | 16 februarie 2008 22:54:15 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <stdio.h>
int st,dr,c;
int n,p;
int main ()
{
freopen ("fact.in","r",stdin);
freopen ("fact.out","w",stdout);
int i,aux;
scanf ("%d",&p);
if (p==0)
{
printf ("1");return 0;
}
st=4*p-1;
dr=5*p+1;
while (st<dr)
{
i=0;
c=(st+dr)/2;
aux=c;
while (aux)
{
i+=aux/5;
aux/=5;
}
if (i==p)
{
printf ("%d",c);return 0;
}
if (i>p)
dr=c;
else if (i<p)
st=c;
}
if (i==p)
printf ("%d",c);
else
printf ("-1");
return 0;
}
