Cod sursa(job #2914496)
Utilizator | Data | 20 iulie 2022 06:45:38 | |
---|---|---|---|
Problema | Factorial | Scor | 45 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <fstream>
using namespace std;
int find(int p) {
int i = 0;
int aux = 0;
if (p == 0)
return 1;
do {
i = i + 5;
aux = i;
while (aux % 5 == 0){
p--;
aux = aux / 5;
}
if (p < 0)
return -1;
} while (p > 0);
return i;
}
int main() {
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
fin>>p;
int n = find(p);
fout<<n;
return 0;
}