結果

問題 No.1869 Doubling?
ユーザー umezo
提出日時 2022-03-12 02:18:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 1,911 ms
コンパイル使用メモリ 191,744 KB
最終ジャッジ日時 2025-01-28 09:13:29
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);

  int n,m;
  cin>>n>>m;
  
  auto f=[&](int x){
    int now=x;
    rep(i,n-1){
      if(now==1) break;
      now=(now+1)/2;
    }
    if(now==1) return true;
    return false;
  };
  
  int ok=1,ng=m+2;
  while(ng-ok>1){
    int mid=(ok+ng)/2;
    if(f(mid)) ok=mid;
    else ng=mid;
  }
  int t=min(ok,m);
  int ans=t,now=t;
  rep(i,n-1){
    now=(now+1)/2;
    ans+=now;
  }
  cout<<ans<<endl;
  
  return 0;
}
0