結果
| 問題 | 
                            No.1286 Stone Skipping
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-02-28 20:41:01 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 843 bytes | 
| コンパイル時間 | 2,058 ms | 
| コンパイル使用メモリ | 193,844 KB | 
| 最終ジャッジ日時 | 2025-02-11 00:16:26 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 42
#endif
using ll = long long;
#define all(a) begin(a), end(a)
#define sz(x) (int)((x).size())
void solve() {
  ll D; cin >> D;
  const auto f = [](int t, ll x) -> ll {
    ll res = 0;
    while (t-- && x) res += x, x >>= 1;
    return res;
  };
  ll ans = D;
  for (int t = 1; t < 65; t++) {
    ll l = 1, r = D, tmp = D;
    while (l <= r) {
      ll m = (l + r) >> 1;
      ll fm = f(t, m);
      if (fm >= D) {
        tmp = m;
        r = m - 1;
      } else {
        l = m + 1;
      }
    }
    if (f(t, tmp) == D) ans = min(ans, tmp);
  }
  cout << ans << "\n";
}
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int T = 1;
  // cin >> T;
  while (T--) solve();
  return 0;
}