Pagini recente » Cod sursa (job #1872305) | Cod sursa (job #65206) | Cod sursa (job #2707390) | Cod sursa (job #2120163) | Cod sursa (job #2914499)
#include <fstream>
#include <cmath>
using namespace std;
int findN(int p) {
int i = 0;
int exp;
if (p == 0)
return 1;
while (p > 0) {
i = i + 5;
exp = (int)(log(i) / log(5));
if (pow(5, exp) == i)
p = p - exp;
else if (i % 25 == 0)
p = p - 2;
else p--;
}
if (p < 0)
return -1;
return i;
}
int main() {
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
fin>>p;
fout<<findN(p);
return 0;
}