結果
問題 |
No.1952 xooooooooooor
|
ユーザー |
|
提出日時 | 2022-05-20 22:21:42 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 723 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 81,992 KB |
実行使用メモリ | 52,224 KB |
最終ジャッジ日時 | 2024-09-20 08:35:23 |
合計ジャッジ時間 | 2,885 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 9 |
ソースコード
MOD = 998244353 n, m = map(int, input().split()) if n == 0: print(0) exit() if m <= 100: tot = 0 for _ in range(m): tot ^= n n <<= 1 print(tot % MOD) else: le = n.bit_length() tot = 0 for _ in range(le): tot ^= n n <<= 1 ans = 0 max_ = le + m - 2 for i in range(le - 1): ans += (tot >> i & 1) * pow(2, i, MOD) ans %= MOD i = le - 1 ans -= (tot >> i & 1) * pow(2, i, MOD) ans %= MOD i = le ans += (tot >> i & 1) * pow(2, max_ - (2 * le - 2 - i), MOD) ans %= MOD for i in range(le, 2 * le - 1): ans += (tot >> i & 1) * pow(2, max_ - (2 * le - 2 - i), MOD) ans %= MOD print(ans)