Pagini recente » Cod sursa (job #189690) | Cod sursa (job #480097) | Cod sursa (job #3272862) | Cod sursa (job #2468025) | Cod sursa (job #3121313)
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
const int N_MAX = 400000015;
int nr_zero(int n) {
int p = 5, cnt = 0;
while(p <= n){
cnt += n / p;
p *= 5;
}
return cnt;
}
int main() {
int p;
fin >> p;
int b = 0, e = N_MAX, mid;//[b;e)
while(e - b > 1){
mid = (b + e) >> 1;
if(nr_zero(mid) < p)
b = mid;
else
e = mid;
}
if(nr_zero(b + 1) == p)
fout << b + 1 << '\n';
else
fout << -1 << '\n';
fin.close();
fout.close();
return 0;
}