結果

問題 No.3254 Xor, Max and Sum
ユーザー nikoro256
提出日時 2025-09-05 22:29:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 290 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,836 KB
実行使用メモリ 54,076 KB
最終ジャッジ日時 2025-09-05 22:29:36
合計ジャッジ時間 3,765 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
if N%2==0:
    print(N*M)
    exit()
if N==1:
    print(0)
    exit()
d = 2**(M.bit_length()-1)
ans = (N-1)*M

rest = M-d
for i in range(M.bit_length()-2,-1,-1):
    if (1<<i)&M==0 and rest - (1<<i) >=0:
        rest -= (1<<i)
        ans += (1<<i)*2
print(ans)
0