結果
問題 |
No.1286 Stone Skipping
|
ユーザー |
![]() |
提出日時 | 2020-12-03 14:11:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,054 bytes |
コンパイル時間 | 2,451 ms |
コンパイル使用メモリ | 191,488 KB |
最終ジャッジ日時 | 2025-01-16 14:22:54 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;} template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;} #define rep(i,n) for(int i=0;i<(n);i++) #define drep(i,n) for(int i=(n)-1;i>=0;i--) #define all(x) (x).begin(),(x).end() #define debug(x) cerr << #x << " = " << (x) << endl; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll D; cin >> D; ll inf = 1e18+10; ll ans = inf; auto calc = [&](int k){ auto val = [&](ll x){ ll sum = 0,now = x; rep(i,k){ sum += now; now /= 2; } return sum; }; ll l = 0,r = inf; while(l+1<r){ ll m = (l+r)/2; (val(m)>=D? r:l) = m; } if(val(r)==D) chmin(ans,r); }; rep(i,60) calc(i); cout << ans << "\n"; }