Mai intai trebuie sa te autentifici.
Cod sursa(job #2093404)
| Utilizator | Data | 23 decembrie 2017 17:07:24 | |
|---|---|---|---|
| Problema | Factorial | Scor | 85 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <cstdio>
int P, N, step;
int trailingZeroes(int N)
{
for(int i = 5, z = 0;; i *= 5)
{
z += N / i;
if(i > N) return z;
}
};
int main(){
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%d", &P);
for(step = 1; step < 400000015; step <<= 1);
for(N = 400000015; step; step >>= 1)
if(trailingZeroes(N - step) >= P) N -= step;
printf("%d", P ? N : 0);
return 0;
}
