Cod sursa(job #2071198)
| Utilizator | Data | 20 noiembrie 2017 14:31:04 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <fstream>
#define LIM 30
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int p;
int nrzero(int nr) {
int s = 0;
while (nr >= 5) {
s += nr / 5;
nr /= 5;
}
return s;
}
int cautbin() {
int pas = 1 << LIM, r = 0;
while (pas != 0) {
if (nrzero(r + pas) < p) {
r += pas;
}
pas >>= 1;
}
return r + 1;
}
int main()
{
in >> p;
//out << nrzero(1220703125) << '\n';
if (nrzero(cautbin()) == p) {
out << cautbin();
}
else {
out << -1;
}
return 0;
}
