Cod sursa(job #2075237)
| Utilizator | Data | 25 noiembrie 2017 12:04:26 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <cstdio>
using namespace std;
int p;
int zero(int x)
{
int s=0;
while(x/5!=0)
{
s+=x/5;
x/=5;
}
return s;
}
int cautbin(int lg,int p)
{
int i;
for(i=0;lg!=0;lg>>=1)
{
if(i+lg<=100000000 && zero(i+lg)>=p)
i+=lg;
}
return i;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
printf("%d",cautbin(134217728,p));
return 0;
}
