Cod sursa(job #1427869)
Utilizator | Data | 3 mai 2015 10:26:57 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#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;
}