結果
問題 | No.1286 Stone Skipping |
ユーザー |
![]() |
提出日時 | 2020-11-13 21:47:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 794 bytes |
コンパイル時間 | 1,623 ms |
コンパイル使用メモリ | 166,864 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 09:51:18 |
合計ジャッジ時間 | 2,643 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)#define rep(i,n) REP(i,0,n)#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)#define ALLOF(c) (c).begin(), (c).end()typedef long long ll;typedef unsigned long long ull;ll solve(ll D, ll x, ll cnt){__int128 p = 0;__int128 xx = x;rep(i,cnt){p += xx;xx /= 2;if(p > (__int128)D) return D+1;}return (ll)(p);}int main(){ll D;cin >> D;ll ret = D;REP(i,1,65){ll lb = 1, ub = D+1;while(ub-lb>1){ll m = lb + (ub-lb)/2;if(solve(D, m, i) < D) lb = m;else ub = m;}ll res = solve(D, ub, i);if(res == D){ret = min(ret, ub);}}cout << ret << endl;return 0;}