結果
| 問題 |
No.1751 Fortune Nim
|
| コンテスト | |
| ユーザー |
hir355
|
| 提出日時 | 2021-11-19 22:53:57 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 170 ms / 2,000 ms |
| コード長 | 403 bytes |
| コンパイル時間 | 138 ms |
| コンパイル使用メモリ | 12,032 KB |
| 実行使用メモリ | 32,224 KB |
| 最終ジャッジ日時 | 2025-01-01 21:03:02 |
| 合計ジャッジ時間 | 4,607 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
MOD = 998244353
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
g = 0
for x in a:
g ^= x
if g == 0:
p = pow(3, s, MOD)
print((p - 1) * pow(2, -1, MOD) * pow(p, -1, MOD) % MOD)
else:
ans = 10 ** 18
for x in a:
if g ^ x <= x:
ans = min(ans, s - (x - (g ^ x)) + 1)
p = pow(3, ans, MOD)
print((p + 1) * pow(2, -1, MOD) * pow(p, -1, MOD) % MOD)
hir355