結果
問題 |
No.1286 Stone Skipping
|
ユーザー |
|
提出日時 | 2025-05-01 19:24:59 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,132 bytes |
コンパイル時間 | 1,360 ms |
コンパイル使用メモリ | 115,168 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-01 19:25:02 |
合計ジャッジ時間 | 2,542 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <math.h> #include <queue> #include <deque> #include <map> #include <set> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define all(a) a.begin(), a.end() #define arr(a) a.rbegin(), a.rend() template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} using ll = long long; //Konishii int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll d; cin >> d; ll ans = ll(2e18); for(int i = 0; i <= 70; i++) { ll ok = 0, ng = d + 1; while(ng - ok > 1) { ll mid = (ok + ng) / 2; ll m = mid; ll res = 0; rep(j, i) { res += m; m /= 2; } if(res > d) ng = mid; else ok = mid; }; ll res = 0; ll m = ok; rep(j, i) { res += m; m /= 2; } if(res == d) chmin(ans, ok); } cout << ans << endl; }