結果
| 問題 | 
                            No.1952 xooooooooooor
                             | 
                    
| コンテスト | |
| ユーザー | 
                             とりゐ
                         | 
                    
| 提出日時 | 2022-05-20 22:46:44 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 485 bytes | 
| コンパイル時間 | 297 ms | 
| コンパイル使用メモリ | 82,048 KB | 
| 実行使用メモリ | 52,608 KB | 
| 最終ジャッジ日時 | 2024-09-20 09:07:23 | 
| 合計ジャッジ時間 | 3,145 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 33 WA * 6 | 
ソースコード
mod=998244353
n,m=map(int,input().split())
s=bin(n)[2:]
if m<100:
  ans=0
  for i in range(m):
    ans^=n<<i
  print(ans%mod)
  exit()
ans=0
ns=len(s)
for i in range(40):
  cnt=0
  for j in range(max(0,ns-i-1),ns):
    cnt+=(s[j]=='1')
  if cnt%2==1:
    ans+=pow(2,i,mod)
for i in range(40):
  cnt=0
  for j in range(min(ns,i+1)):
    cnt+=(s[j]=='1')
  if cnt%2==1:
    ans+=pow(2,ns+m-i-2,mod)
if s.count('1')%2==1:
  ans+=pow(2,ns+m-41,mod)-pow(2,40,mod)
  ans%=mod
print(ans)
            
            
            
        
            
とりゐ