結果
問題 |
No.1286 Stone Skipping
|
ユーザー |
|
提出日時 | 2025-02-05 03:52:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 486 bytes |
コンパイル時間 | 1,228 ms |
コンパイル使用メモリ | 82,072 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-02-05 03:52:08 |
合計ジャッジ時間 | 2,829 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <cassert> #include <iostream> #include <vector> using namespace std; using ll = long long; ll D; ll check(ll x, int t) { ll res = x; while(t--) { x /= 2; res += x; if(res > D) return (ll)3e18; } return res; } int main() { cin >> D; ll ans = 1e18; for(int K = 0; K <= 62; K++) { ll ok = D, ng = 0; while(ok - ng > 1) { ll mi = (ok + ng) / 2; (check(mi, K) >= D ? ok : ng ) = mi; } if(check(ok, K) == D) ans = min(ans, ok); } cout << ans << endl; }