Pagini recente » Istoria paginii utilizator/oanaoanaoana | Rating Mitrea Andrei (Squidward) | Cod sursa (job #1573400) | Monitorul de evaluare | Cod sursa (job #1861679)
#include <fstream>
using namespace std;
const int kMaxVal = 1e8;
int FiveFactors(int x)
{
int five_pow = 5;
int factors = 0;
while (five_pow <= x) {
factors += x / five_pow;
five_pow *= 5;
}
return factors;
}
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int n;
fin >> n;
int pow = (1 << 30);
int pos = -1;
while (pow > 0) {
if (FiveFactors(pos + pow) < n) {
pos += pow;
}
pow >>= 1;
}
fout << pos + 1 << "\n";
return 0;
}