結果
問題 |
No.1286 Stone Skipping
|
ユーザー |
|
提出日時 | 2020-11-13 21:46:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 643 bytes |
コンパイル時間 | 2,046 ms |
コンパイル使用メモリ | 167,336 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-22 20:38:07 |
合計ジャッジ時間 | 2,175 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 6 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; bool ok(ll a, ll d){ ll x = a; while(x != 0){ x /= 2; a += x; } return (a >= d); } int main(){ cin.tie(0); ios::sync_with_stdio(0); ll D; cin >> D; ll r = D+10; ll l = 0; while(r - l > 1){ ll mid = (r + l) / 2; if(ok(mid, D)) r = mid; else l = mid; } bool ok = false; ll s = r, x = r; while(x > 0){ if(s == D) ok = true; x /= 2; s += x; } if(ok) cout << r << endl; else cout << D << endl; }