No.2874 Gunegune Tree
タグ : / 解いたユーザー数 68
作問者 :
寝癖
/ テスター :
Problem Statement
Neguse-kun has bought the seed of a mysterious plant. He is going to grow it at his home starting today.
Let today be day $0$. Each time $1$ day passes, this plant grows according to the following rules.
- On day $0$, the tip of the plant is at the origin $(0,0)$ of a $2$-dimensional plane.
- If the coordinates of the tip of the plant on day $i\ (\ge0)$ are $(x,y)$, then the coordinates of the tip on day $i+1$ are one of $(x+1,y),(x+1,y+1),(x,y+1),(x-1,y+1),(x-1,y)$. That is, it grows in one of the following directions: right, upper right, up, upper left, or left.
- Let $P_i,P_{i+1},P_{i+2}$ be the positions of the tip of the plant on days $i,i+1,i+2$. Then $\angle P_iP_{i+1}P_{i+2}>90^\circ$ holds. That is, the plant never bends at an acute or right angle.
- The direction of growth is chosen independently and uniformly at random from all possible directions.
Neguse-kun is troubled by the low ceiling of his home, and he is very concerned about how tall this plant will grow.
Find the expected value of the height of the plant (that is, the $y$-coordinate of its tip) on day $N$ after he starts growing it, modulo ${\rm mod}\ 998244353$.
What is an expected value ${\rm mod}\ 998244353$?
It can be proved that the expected value to be found is always a rational number. Moreover, under the constraints of this problem, it is guaranteed that when the expected value is expressed as an irreducible fraction $\frac{p}{q}$, $q$ is not divisible by $998244353$. In this case, there exists a unique $0\le r < 998244353$ satisfying $p=qr\ ({\rm mod}\ 998244353)$, so output this $r$.
Input
$N$
- $1\le N\le 2\times 10^5$
- $N$ is an integer.
Output
Output the expected value of the height of the plant on day $N$, ${\rm mod}\ 998244353$, on a single line.
Sample
Sample 1
Input
1
Output
798595483
On day $1$, the plant grows in one of $5$ directions with equal probability.
If it grows to the upper right, up, or to the upper left, the height becomes $1$, and if it grows to the right or left, the height becomes $0$. Therefore, the expected value to be found is $1\times\frac35+0\times\frac25 = \frac35$.
Sample 2
Input
2
Output
465847366
Sample 3
Input
3
Output
277290100
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。