結果

問題 No.1869 Doubling?
ユーザー shiomusubi496shiomusubi496
提出日時 2021-11-23 14:41:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 190,804 KB
最終ジャッジ日時 2025-01-26 00:40:55
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

using ll = long long;

int main(){
    ll N, X; cin >> N >> X;
    if (N <= 60 && (1ll << (N - 1)) <= X) {
        cout << (1ll << N) - 1 << endl;
    }
    else {
        ll ans = 0;
        while (X != 1) {
            ans += X;
            X = (X + 1) / 2;
            --N;
        }
        ans += N;
        cout << ans << endl;
    }
}
0