結果

問題 No.1869 Doubling?
ユーザー srjywrdnprkt
提出日時 2023-05-21 05:32:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 104,328 KB
最終ジャッジ日時 2025-02-13 03:56:02
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll N, M, ans=0;
    cin >> N >> M;
    if (N < 40) M = min(M, 1LL<<(N-1));
    while(M != 1 && N != 0){
        ans += M;
        if (M % 2 == 0) M /= 2;
        else M = (M+1)/2;
        N--;
    }

    cout << ans+N << endl;

    return 0;
}
0