Language: C++

//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr, bool order = true){ sort(arr.begin(), arr.end(), order ? less<>() : greater<>()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N, K;
    cin >> N >> K;
    // 最初のサイコロだけでうまくいく場合
    double p = max(double(N - K) / N, 0.0);
    //
    rep(i, min(K-1,N))
    {
        ll s = i + 1;
        ll needScale = (K + s - 1) / s - 1;
        ll odds = 1;
        while (needScale != 0)
        {
            needScale >>= 1;
            odds *= 2;
        }
        p += 1.0 / double(odds*N);
    }
    //
    outD(p);
    //
    return 0;
}

Compiler output:
a.cc: In function 'void sort(Type&, bool)':
a.cc:23:108: error: operands to '?:' have different types 'std::less<void>' and 'std::greater<void>'
   23 | template<typename Type> inline void sort(Type& arr, bool order = true){ sort(arr.begin(), arr.end(), order ? less<>() : greater<>()); }
      |                                                                                                      ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc: At global scope:
a.cc:26:22: error: 'numeric_limits' was not declared in this scope
   26 | constexpr ll INF_I = numeric_limits<ll>::max();
      |                      ^~~~~~~~~~~~~~
a.cc:26:39: error: expected primary-expression before '>' token
   26 | constexpr ll INF_I = numeric_limits<ll>::max();
      |                                       ^
a.cc:26:45: error: no matching function for call to 'max()'
   26 | constexpr ll INF_I = numeric_limits<ll>::max();
      |                                        ~~~~~^~
In file included from /usr/include/c++/14/vector:62,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 0 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 0 provided
a.cc:28:26: error: 'numeric_limits' was not declared in this scope
   28 | constexpr double INF_F = numeric_limits<float>::infinity();
      |                          ^~~~~~~~~~~~~~
a.cc:28:41: error: expected primary-expression before 'float'
   28 | constexpr double INF_F = numeric_limits<float>::infinity();
      |                                         ^~~~~