Cod sursa(job #569572)
| Utilizator | Data | 1 aprilie 2011 18:47:28 | |
|---|---|---|---|
| Problema | Factorial | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.39 kb |
#include<stdio.h>
int zero(int n)
{
int s=0,p=5;
while(n>=p)
{
s+=n/p;
p=p*5;
}
return s;
}
int caut(int p)
{
int i,pas=1<<26;
for(i=0;pas!=0;pas=pas/2)
{
if(zero(i+pas)<p)
i+=pas;
}
return 1+i;
}
int main()
{
int n,p;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
n = caut(p);
printf("%d",n);
return 0;
}
