問題一覧 > 通常問題

No.1751 Fortune Nim

レベル : / AI推定難易度 : 2525 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 37
作問者 : torisasami4 / テスター : tokusakurai sapphire__15
お気に入りにしたユーザー ProblemId : 7250 / 自分の提出
問題文最終更新日: 2021-11-06 15:22:35
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 323 (順位表) の他の問題:

Problem Statement

There are $N$ piles of stones and $1$ coin. Initially, the $i\ (1 \le i \le N)$-th pile contains $a_i$ stones.

Using these, $2$ players, Alice and Bob, play a game. When the coin is tossed, heads and tails each come up with probability $\large \frac{1}{2}$.

The game starts with Alice's turn, and the player whose turn it is performs the following operations 1 to 3 in order from the top.


  1. Choose $1$ pile that has $1$ or more stones remaining. Suppose the chosen pile has $x$ stones remaining.

  2. Declare $1$ integer $k$ satisfying $1 \le k \le x$, then toss the coin. If it comes up heads, remove $k$ stones from the chosen pile. If it comes up tails, do nothing.

  3. If operation 2 has resulted in a state where not even $1$ stone remains in any pile, the player whose turn it is wins and the game ends. Otherwise, the turn passes to the opponent.


Find the probability that Alice wins when both Alice and Bob act to maximize their own probability of winning.

It can be proved that the answer can be expressed as an irreducible fraction $\large \frac{p}{q}$ and that there is a unique integer $r$ satisfying $r \times q \equiv p\ (\textrm{mod}\ 998244353)$ and $0 \le r \lt 998244353$. Output this $r$.

Input

$N$
$a_1\ a_2\ \ldots\ a_N$

【Constraints】

  • $1 \le N \le 2\times10^5$

  • $1 \le a_i \le 10^9$

  • All inputs are integers.

Output

Output the answer $\textrm{mod}\ 998244353$.

Sample

Sample 1
Input
1
100
Output
665496236

Both players try to take all the stones from the only $1$ pile, and they take turns tossing the coin; whoever gets heads first wins. The probability that Alice wins is $\large \frac{2}{3}$.

Sample 2
Input
2
1 1
Output
776412275

Both players can only ever choose a pile with stones remaining and declare $k=1$. The probability that Alice wins is $\large \frac{4}{9}$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。