Cod sursa(job #1427871)
Utilizator | Data | 3 mai 2015 10:30:27 | |
---|---|---|---|
Problema | Factorial | Scor | 95 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 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);
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;
}