結果
問題 |
No.1869 Doubling?
|
ユーザー |
![]() |
提出日時 | 2022-03-12 02:15:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,556 ms / 2,000 ms |
コード長 | 627 bytes |
コンパイル時間 | 1,771 ms |
コンパイル使用メモリ | 192,864 KB |
最終ジャッジ日時 | 2025-01-28 09:12:59 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n,m; cin>>n>>m; auto f=[&](ll x){ ll now=x; rep(i,n-1){ if(now==1) break; now=(now+1)/2; } if(now==1) return true; return false; }; ll ok=1,ng=m+2; while(ng-ok>1){ ll mid=(ok+ng)/2; if(f(mid)) ok=mid; else ng=mid; } ll t=min(ok,m); ll ans=t; ll now=t; rep(i,n-1){ now=(now+1)/2; ans+=now; } cout<<ans<<endl; return 0; }