結果
問題 |
No.1952 xooooooooooor
|
ユーザー |
![]() |
提出日時 | 2022-04-10 19:24:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 38 ms / 2,000 ms |
コード長 | 659 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 53,636 KB |
最終ジャッジ日時 | 2024-12-21 10:10:41 |
合計ジャッジ時間 | 2,641 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 |
ソースコード
N,M = map(int, input().split()) if not(0<=N<=10**9 and 1<=M<=10**9): exit() mod = 998244353 BITN = format(N,'b') bitnlen = len(BITN) if M>=len(BITN): HIGH = [] temp = 0 for b in BITN: temp^=int(b) HIGH.append(temp) LOWr = [] temp = 0 for b in BITN[::-1]: temp^=int(b) LOWr.append(temp) ans = 0 for i in range(bitnlen): ans += LOWr[i]*pow(2,i,mod) for i in range(bitnlen): ans += HIGH[i]*pow(2,bitnlen+M-2-i,mod) if BITN.count('1')%2==1: ans += pow(2,M-1,mod)-pow(2,bitnlen,mod) else: ans = 0 for i in range(M): ans^=N*pow(2,i) print(ans%mod)