Pagini recente » Cod sursa (job #1451103) | Cod sursa (job #832631) | Cod sursa (job #306127) | Cod sursa (job #1533471) | Cod sursa (job #2699422)
//ALEXANDRU MICLEA
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
#include <chrono>
#include <assert.h>
#include <iostream>
using namespace std;
using ll = long long;
#define fast_cin() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//VARIABLES
//FUNCTIONS
ll zero(ll val) {
ll tot = 0;
ll m5 = 5;
while (m5 <= val) {
tot += (val / m5);
m5 *= 5;
}
return tot;
}
//MAIN
int main() {
#ifdef INFOARENA
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
#endif
fast_cin();
ll p; cin >> p;
if (p == 0) {
cout << '1';
return 0;
}
ll ans = -1;
ll st = 1, dr = 10000000000;
while (st <= dr) {
ll mid = (st + dr) / 2;
int val = zero(mid);
if (val == p) ans = mid;
if (val < p) st = mid + 1;
else dr = mid - 1;
}
cout << ans << '\n';
return 0;
}