結果

問題 No.1286 Stone Skipping
ユーザー 0w1
提出日時 2020-11-13 22:02:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 492 bytes
コンパイル時間 1,666 ms
コンパイル使用メモリ 191,900 KB
最終ジャッジ日時 2025-01-15 22:58:27
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int64_t D; { cin >> D; }

  int64_t lb = 0;
  int64_t ub = D;
  while (ub - lb > 1) {
    int64_t mb = lb + ub >> 1;
    int64_t s = 0;
    for (int64_t u = mb; u; u >>= 1) {
      s += u;
    }
    (s >= D ? ub : lb) = mb;
  }

  auto test = [D](int64_t v) {
    int64_t r = 0;
    while (v && r < D) r += v, v /= 2;
    return r == D;
  };

  while (!test(ub)) ub += 1;

  cout << ub << endl;
}

0