Pagini recente » Cod sursa (job #3240737) | Cod sursa (job #531970) | Cod sursa (job #911997) | Cod sursa (job #3209197) | Cod sursa (job #3245830)
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int count_factors_of_5(int n) {
int count = 0;
while (n > 0) {
n /= 5;
count += n;
}
return count;
}
int find_smallest_N_with_exactly_P_zeros(int p) {
int low = 0, high = p * 5;
while (low < high) {
int mid = (low + high) / 2;
if (count_factors_of_5(mid) < p) {
low = mid + 1;
} else {
high = mid;
}
}
return low;
}
int main() {
int p;
fin >>p;
fout << find_smallest_N_with_exactly_P_zeros(p);
return 0;
}