結果

問題 No.1869 Doubling?
ユーザー elphe
提出日時 2024-11-13 17:25:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 361 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 66,600 KB
最終ジャッジ日時 2025-02-25 04:06:00
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	uint32_t N, M;
	cin >> N >> M;

	uint64_t ans = 0;
	if (N <= 31 && M >= (1u << (N - 1))) cout << (1u << N) - 1 << '\n';
	else
	{
		for (; N != 0 && M != 1; --N, M = (M + 1) >> 1)
			ans += M;

		cout << ans + N << '\n';
	}
	return 0;
}
0