結果

問題 No.1869 Doubling?
ユーザー cologne
提出日時 2022-03-11 22:02:48
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 1,781 ms
コンパイル使用メモリ 163,392 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-16 02:19:53
合計ジャッジ時間 2,896 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    int N, M;
    cin >> N >> M;
    long long ans = 0;
    int i = 0;
    int last_add = M;
    for (i = 0; i < N && last_add != 1; ++i)
    {
        ans += M;
        last_add = M;
        M = (M + 1) / 2;
    }
    if(i == N && last_add != 1)
    {
        cout << ((1<<N)-1) << endl;
        return 0;
    }
    ans += N - i;
    cout << ans << endl;
}
0