Cod sursa(job #2075216)
Utilizator | Data | 25 noiembrie 2017 11:57:36 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <cstdio>
using namespace std;
int p,lg=134217728;
int zero(int x)
{
int s=0;
while(x/5 != 0)
{
s+=(x/5);
x/=5;
}
return s;
}
int cautbin()
{
int i;
for(lg, i=100000000;lg;lg>>=1)
if(i - lg >0 && 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());
return 0;
}