#P13606. [NWRRC 2022] IQ Game

[NWRRC 2022] IQ Game

题目描述

A popular TV show "Kak? Zachem? Pochemu?" highlights a team of six players working together to solve challenging questions. Players sit around a circular table divided into nn sectors numbered clockwise from 11 to nn. At the start of the game, each sector contains an envelope with a question to be answered.

Each round, the spinning top at the center of the table chooses a sector of the table uniformly at random. If the chosen sector contains an envelope, the host opens it and reads the question inside. If there is no envelope in the chosen sector, the host opens the next envelope in the clockwise direction from the chosen sector instead. After the round, the opened envelope is removed from the table.

Tonight, the audience's favorite team is playing. They have already played nkn - k rounds out of nn, so there are kk envelopes remaining on the table. Things are not looking good for the team --- one more incorrect answer will send them home. One of the questions is a special, notoriously hard question called "Hyperblitz". The team is confident they can answer each of the remaining questions except "Hyperblitz". Find the expected number of rounds they will play, modulo 998244353998\,244\,353 (see the Output section for details).

输入格式

The first line contains three integers nn, kk, and ss --- the total number of sectors, the number of remaining questions, and the sector containing the "Hyperblitz" question (1n1091 \le n \le 10^9; 1kmin(n,200)1 \le k \le \min(n, 200); 1sn1 \le s \le n). It is guaranteed that nn is not equal to 998244353998\,244\,353.

The second line contains kk distinct integers q1,q2,,qkq_1, q_2, \ldots , q_k --- the numbers of sectors that still have envelopes, in clockwise order (1q1<q2<<qkn1 \le q_1 < q_2 < \ldots < q_k \le n).

There is exactly one index ii with qi=sq_i = s.

输出格式

Print a single integer --- the expected number of rounds the team will play (including the inevitable "Hyperblitz"), modulo 998244353998\,244\,353.

Formally, let M=998244353M = 998\,244\,353. It can be shown that the expected number of rounds can be expressed as an irreducible fraction pq\frac{p}{q}, where pp and qq are integers and q≢0(modM)q \not \equiv 0 \pmod{M}. Print the integer equal to pq1modMp \cdot q^{-1} \bmod M. In other words, print such an integer xx that 0x<M0 \le x < M and xqp(modM)x \cdot q \equiv p \pmod{M}.

3 2 3
2 3
665496237
6 3 4
1 2 4
582309208
8 8 5
1 2 3 4 5 6 7 8
499122181

提示

In the first example test, in the first round, the team plays the "Hyperblitz" with probability 13\frac 13, so with probability 13\frac 13 they play 1 round, and with probability 23\frac 23 they play 2 rounds. The expected number of rounds is 113+223=531 \cdot \frac 13 + 2 \cdot \frac 23 = \frac 53.

As 31mod998244353=3327481183^{-1} \bmod {998\,244\,353} = 332\,748\,118, the correct output is $5 \cdot 332\,748\,118 \bmod {998\,244\,353} = 665\,496\,237$.