Cod sursa(job #354738)
| Utilizator | Data | 9 octombrie 2009 12:07:44 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<stdio.h>
int nzero(int n)
{
int r=0;
while (n)
r+=(n/=5);
return r;
}
int cb(int p)
{
int i,pas=(1<<30);
--p;
for (i=0 ; pas ; pas>>=1)
if (nzero(i+pas)<=p)
i += pas;
if (nzero(i+1)!=(p+1)) return -1;
return i+1;
}
int main()
{int p;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
printf("%d",cb(p));
return 0;
}