結果
問題 |
No.1286 Stone Skipping
|
ユーザー |
|
提出日時 | 2020-11-14 00:44:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 673 bytes |
コンパイル時間 | 1,607 ms |
コンパイル使用メモリ | 167,332 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 09:55:49 |
合計ジャッジ時間 | 2,512 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr char newl = '\n'; ll calc(ll x, ll lim) { ll res = 0; while (x >= lim) { res += x; x >>= 1; } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll d; cin >> d; ll lim = 1; ll ans = d; while (true) { ll ng = 0, ok = d; while (ok - ng > 1) { ll mid = (ok + ng) / 2; (calc(mid, lim) >= d ? ok : ng) = mid; } if (calc(ok, lim) == d) { ans = ok; break; } lim <<= 1; } cout << ans << newl; return 0; }