結果
問題 |
No.1286 Stone Skipping
|
ユーザー |
![]() |
提出日時 | 2020-11-19 08:23:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,145 bytes |
コンパイル時間 | 2,175 ms |
コンパイル使用メモリ | 191,580 KB |
最終ジャッジ日時 | 2025-01-16 01:40:10 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define rep(i, n) repl(i, 0, n) #define CST(x) cout << fixed << setprecision(x) using ll = long long; const ll MOD = 1000000007; const int inf = 1e9 + 10; const ll INF = (ll)4e18 + 10; const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0}; const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0}; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); ll d; cin >> d; ll l = -1, r = d + 1, ans = d; while (r - l > 1) { ll m = (l + r) / 2; ll sum = 0, t = m; while (t) { sum += t; t /= 2; if (sum == d) chmin(ans, m); } if (sum >= d) { r = m; } else { l = m; } if (sum == d) chmin(ans, r); } cout << ans << endl; return 0; }