結果

問題 No.1869 Doubling?
ユーザー SSRSSSRS
提出日時 2022-03-11 21:27:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 534 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 191,916 KB
最終ジャッジ日時 2025-01-28 08:11:01
ジャッジサーバーID
(参考情報)
judge2 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  bool ok = false;
  if (N <= 30){
    if (M > (1 << N)){
      ok = true;
    }
  }
  if (ok){
    long long ans = 0;
    for (int i = 0; i < N; i++){
      ans += 1 << i;
    }
    cout << ans << endl;
  } else {
    long long ans = 0;
    while (true){
      if (M == 1){
        ans += N;
        assert(N >= 1);
        break;
      } else {
        ans += M;
        M = (M + 1) / 2;
        N--;
      }
    }
    cout << ans << endl;
  }
}
0