結果

問題 No.1869 Doubling?
ユーザー Nzt3
提出日時 2022-09-25 01:47:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 469 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 192,384 KB
最終ジャッジ日時 2025-02-07 14:39:33
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin>>N>>M;
  if(N<=30&&(1<<N-1)<=M){
    long long ans=0;
    for(int i=0;i<N;i++){
      ans+=1<<N;
    }
    cout<<ans<<'\n';
    return 0;
  }
  long long ans=0;
  int t=M;
  for(int i=0;i<N;i++){
    if(t==1){
      ans+=(N-i);
      break;
    }
    ans+=t;
    if(t%2){
      t=(t+2)/2;
    }else{
      t=t/2;
    }
  }
  cout<<ans<<'\n';
}
0