Cod sursa(job #1452468)
| Utilizator | Data | 20 iunie 2015 22:55:04 | |
|---|---|---|---|
| Problema | Factorial | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
#define MIN(a,b) ((a)<(b))?(a):(b)
const char IN[] = "fact.in", OUT[] = "fact.out";
using namespace std;
int P;
inline void read_data() {
fscanf(fopen(IN, "r"), "%d", &P);
}
int perm_count_zeros(int P) {
if (P == 0) return 1;
int nr5 = 1;
int i = 5;
while (nr5 != P) {
i+=5;
int aux = i;
while (aux % 5 == 0) aux /= 5, ++nr5;
}
return i;
}
int main() {
read_data();
fprintf(fopen(OUT, "w"), "%d\n", perm_count_zeros(P));
return 0;
}