Pagini recente » Cod sursa (job #2544280) | Cod sursa (job #1632358) | Cod sursa (job #1007867) | Cod sursa (job #1468491) | Cod sursa (job #1238326)
#include <fstream>
using namespace std;
int N, sol, cnt;
ifstream fin("fact.in");
ofstream fout("fact.out");
bool Check(int val) {
cnt = 0;
for (int fact = 5; fact <= val; fact *= 5)
cnt += val / fact;
if (cnt < N)
return true;
return false;
}
int main() {
fin >> N;
for (int bit = 1 << 30; bit; bit >>= 1) {
if (Check(sol | bit))
sol |= bit;
}
if (cnt == N)
fout << sol + 1 << "\n";
else
fout <<"-1\n";
return 0;
}