Pagini recente » Cod sursa (job #1430505) | Cod sursa (job #1411762) | Cod sursa (job #1434957) | Diferente pentru problema/retele intre reviziile 3 si 7 | Cod sursa (job #1427869)
#include <fstream>
using namespace std;
int main() {
ifstream fi("fact.in");
ofstream fo("fact.out");
long p;
fi >> p;
long r = p;
p *= 4;
long ans = 5 * ((p / 5) + 1);
while (true) {
long aux = ans;
long v = ans;
while (aux > 0) {
v -= aux % 5;
aux /= 5;
}
if (v == r) {
fo << ans;
break;
}
if (v > r) {
fo << -1;
break;
}
ans += 5;
}
return 0;
}