結果
| 問題 | 
                            No.3254 Xor, Max and Sum
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-09-05 22:20:04 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 433 bytes | 
| コンパイル時間 | 223 ms | 
| コンパイル使用メモリ | 82,372 KB | 
| 実行使用メモリ | 54,152 KB | 
| 最終ジャッジ日時 | 2025-09-05 22:20:15 | 
| 合計ジャッジ時間 | 3,654 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 WA * 27 | 
ソースコード
n, m = map(int, input().split())
if n == 1:
    print(0)
    exit()
if n % 2 == 0:
    print(m * n)
    exit()
草 = [0] * (35)
s = bin(m)[2:].zfill(35)
f = -1
for i in range(0, 35):
    if s[i] == "1" and f == -1:
        f = i
    草[i] = (n-2 if s[i] == "1" else 0)
for i in range(f+1, 35):
    草[i] += 1
ans = 0
for i in range(35):
    ans += 草[i] * (2**(34-i))
    if 草[i] % 2 == 1:
        ans += (2**(34-i))
print(ans)