結果

問題 No.3254 Xor, Max and Sum
ユーザー Iroha_3856
提出日時 2025-09-05 04:07:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 210 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 53,732 KB
最終ジャッジ日時 2025-09-05 05:31:50
合計ジャッジ時間 3,557 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())

if N%2 == 0:
	print(N*M)
	exit()
c = 0
ans = 0
for b in range(29, -1, -1):
	if M>>b&1:
		ans += (N-1) * (1<<b)
		if c < N: c += 1
	else:
		ans += (c//2 * 2) * (1<<b)
print(ans)
0