Pagini recente » Cod sursa (job #149579) | Cod sursa (job #2122682) | Cod sursa (job #2338132) | Cod sursa (job #765997) | Cod sursa (job #2075400)
#include <iostream>
#include <fstream>
#include <queue>
#include <cstdlib>
#if 1
#define pv(x) cout<<#x<<" = "<<x<<"; ";cout.flush()
#define pn cout<<endl
#else
#define pv(x)
#define pn
#endif
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
const int NMax = 2e5 + 5;
const int mod = 666013;
ll P;
ll getNr(ll);
int main() {
in>>P;
ll pw = 1,pos = 0,lim = 1e9;
for (;pw <= lim; pw <<= 1) ;
pw >>= 1;
while (pw) {
if (getNr(pos+pw) < P) {
pos += pw;
}
pw >>= 1;
}
if (getNr(pos+1) == P) {
out<<pos+1;
}
else {
out<<"-1\n";
}
return 0;
}
ll getNr(ll nr) {
ll ans = 0;
ll pw = 5;
while (pw <= nr) {
ans += nr / pw;
pw *= 5;
}
return ans;
}