Cod sursa(job #1507928)
| Utilizator | Data | 22 octombrie 2015 00:39:34 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.39 kb |
#include<stdio.h>
int p, ok = 0, i = 0, cont = 0;
void fct(int x) {
int c;
if (x % 5 == 0) {
++cont;
c = x / 5;
fct(c);
}
}
int main() {
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%d", &p);
if (p < 0) {
printf("%d", -1);
return 0;
}
while (!ok) {
++i;
fct(i);
if (cont >= p)ok = 1;
}
printf("%d", i);
return 0;
}