Pagini recente » Cod sursa (job #95625) | Cod sursa (job #2608524) | Cod sursa (job #2414320) | Cod sursa (job #978932) | Cod sursa (job #2959884)
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
/// INPUT / OUTPUT
ifstream fin("fact.in");
ofstream fout("fact.out");
/// GLOBAL VARIABLES
ll n, ans;
ll countzero(ll num)
{
int cnt = 0;
while(num >= 5)
{
num /= 5;
cnt+=num;
}
return cnt;
}
/// SOLUTION
inline void solve()
{
if(n == 0)
{
fout << 1;
return;
}
int st = 1, dr = 1e18;
while(st <= dr)
{
ll mid = (st + dr) / 2;
ll c = mid;
ll zero = countzero(mid);
if(zero == n)
{
ans = c;
dr = mid - 1;
}
if(zero > n)
{
dr = mid - 1;
}
if(zero < n)
{
st = mid + 1;
}
}
fout << ans;
}
/// READING THE INPUT
int main()
{
ios::sync_with_stdio(false);
fin.tie(NULL);
fout.tie(NULL);
fin >> n;
solve();
}