Pagini recente » Cod sursa (job #955308) | Cod sursa (job #1509306) | Cod sursa (job #3157270) | Cod sursa (job #639252) | Cod sursa (job #1427872)
#include <fstream>
using namespace std;
int main() {
ifstream fi("fact.in");
ofstream fo("fact.out");
long p;
fi >> p;
if (p == 0) {
fo << 1;
return 0;
}
p *= 4;
long ans = 5 * (p / 5);
while (true) {
long aux = ans;
long v = ans;
while (aux > 0) {
v -= aux % 5;
aux /= 5;
}
if (v == p) {
fo << ans;
break;
}
if (v > p) {
fo << -1;
break;
}
ans += 5;
}
return 0;
}