Pagini recente » Cod sursa (job #1939057) | Cod sursa (job #787023) | Cod sursa (job #592957) | Cod sursa (job #453777) | Cod sursa (job #2739649)
#include <fstream>
int p, n=1, c=1;
long long int factorial = 1;
bool gasit = false;
int nrzero(int x) {
int c = 0;
while (x) {
if (x % 10 == 0) c++;
x %= 10;
}
return c;
}
int main() {
std::ifstream fin("fact.in");
std::ofstream fout("fact.out");
fin >> p;
if(p < 0) return 0;
while (factorial < 999999999999999 ) {
factorial = 1;
for (int i = 1; i <= c; i++) {
factorial *= i;
}
if (nrzero(factorial) == p) {
fout << factorial;
gasit = true;
break;
}
c++;
}
if (gasit == false) fout << -1;
}