Pagini recente » Cod sursa (job #453923) | Cod sursa (job #2298144) | Cod sursa (job #2064348) | Cod sursa (job #170063) | Cod sursa (job #906883)
Cod sursa(job #906883)
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int zero(int n) {
int rez = 0, p = 5;
while (p <= n) {
rez += n/p;
n /= p;
}
return rez;
}
int caut(int p) {
int i = 0, pas = 1<<29;
while (pas != 0) {
if (zero(i + pas) < p)
i += pas;
pas /= 2;
}
return i + 1;
}
int main()
{
int x, r;
in >> x;
r = caut(x);
if (zero(r) == x)
out << r;
else out << -1;
return 0;
}