Cod sursa(job #2025838)
| Utilizator | Data | 23 septembrie 2017 12:48:49 | |
|---|---|---|---|
| Problema | Factorial | Scor | 35 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <stdio.h>
int getN(int p) {
if ( p == 0 )
return 1;
const unsigned long long NMAX = (1LL << 63);
int i = 0, _i = 0, num = 0;
for ( i = 1; i < NMAX; ++i ) {
_i = i;
while( _i % 5 == 0 ) {
_i /= 5;
num ++;
}
if ( num == p )
return i;
if ( num > p )
return -1;
}
}
main() {
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
int p, res;
scanf("%d", &p);
res = getN(p);
printf("%d", res);
}