Pagini recente » Cod sursa (job #2984686) | simulare_republicana_6 | Cod sursa (job #218373) | Cod sursa (job #1555577) | Cod sursa (job #3206246)
#include <iostream>
#include <limits.h>
#include <queue>
#include <string>
#include <map>
#include<vector>
#include <set>
#include<stack>
#include <queue>
#include<algorithm>
#include <fstream>
#include <iomanip>
#include<cmath>
#include<iostream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int getNumberOfFives(int x) {
int l = 5, ans=0;
while (l <= x) {
ans += x / l;
l *= 5;
}
return ans;
}
int main()
{
int p;
in >> p;
int st = 1, dr=5e8;
if (p == 0) {
out << 1;
return 0;
}
while (st <= dr) {
int mijl = (dr + st) / 2;
if (getNumberOfFives(mijl) < p) {
st = mijl + 1;
}
else {
dr = mijl-1;
}
}
if (getNumberOfFives(st) == p)out << st;
else out << -1;
return 0;
}