結果

問題 No.1286 Stone Skipping
ユーザー 0w1
提出日時 2020-11-13 22:01:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 476 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 191,660 KB
最終ジャッジ日時 2025-01-15 22:57:38
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 res = 0;
  int64_t d = D;
  for (int i = 60; ~i; --i) {
    int64_t v = (int64_t) 1 << i + 1;
    v -= 1;
    if (d >= v) {
      d -= v;
      res |= v + 1 >> 1;
    }
  }

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

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

  cout << res << endl;
}

0