結果
| 問題 |
No.1952 xooooooooooor
|
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2022-05-20 22:05:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 2,000 ms |
| コード長 | 871 bytes |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 82,264 KB |
| 実行使用メモリ | 54,528 KB |
| 最終ジャッジ日時 | 2024-09-20 08:14:15 |
| 合計ジャッジ時間 | 3,082 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 39 |
ソースコード
"""
"""
import sys
from sys import stdin
from collections import deque
import heapq
def popcnt(X):
ret = 0
while X:
ret += X % 2
X //= 2
return ret % 2
N,M = map(int,stdin.readline().split())
NR = N.bit_length()
mod = 998244353
if M <= 70:
ans = 0
for i in range(M):
ans ^= N
N *= 2
print (ans % mod)
else:
minbit = 0
NN = N
for i in range(70):
minbit ^= NN
NN *= 2
maxbit = 0
NN = N
for i in range(70):
maxbit ^= NN
NN //= 2
ans = 0
cnt = popcnt(N)
if cnt == 0:
pass
else:
ans += ( pow(2,M-NR+1,mod)-1 ) * pow(2,NR-1,mod)
ans %= mod
for i in range(NR-1):
ans += minbit & (2**i)
for i in range(1,NR):
ans += (maxbit & (2**i)) * pow(2,M-1,mod)
ans %= mod
print (ans)
SPD_9X2