結果
問題 | No.1952 xooooooooooor |
ユーザー |
👑 |
提出日時 | 2022-05-20 22:23:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 729 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-09-20 08:37:09 |
合計ジャッジ時間 | 2,657 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 |
ソースコード
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) & 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)