No.3698 Team Division by Lottery
タグ : / 解いたユーザー数 27
作問者 :
Problem Statement
$N$ participants are randomly divided into $K$ teams. $N$ is a multiple of $K$, and every team has exactly $N/K$ members.
All such divisions are chosen with equal probability. Each participant $i$ has $2$ integers $A_i, B_i$, and when participants $i$ and $j$ are on the same team, a friendship value of $A_i B_j + A_j B_i$ is obtained.
Find the expected value of the total friendship value obtained, modulo $998244353$.
Input
$N\ K$ $A_1\ A_2\ \cdots\ A_N$ $B_1\ B_2\ \cdots\ B_N$
$2 \le N \le 2 \times 10^5$
$1 \le K \le N$, and $K$ divides $N$
$0 \le A_i, B_i < 998244353$
All inputs are integers
Output
Output the expected value modulo $998244353$. The value to be found is always a rational number, and its denominator is coprime to $998244353$. Print a newline at the end.
Sample
Sample 1
Input
4 2 1 2 3 4 1 1 1 1
Output
10
The probability that any given pair is on the same team is $(2-1)/(4-1) = 1/3$. The total friendship value over all pairs is $30$, so the expected value is $10$.
Sample 2
Input
2 1 5 7 2 3
Output
29
Since $K = 1$, the $2$ participants are always on the same team. Exactly $5 \times 3 + 7 \times 2 = 29$ is always obtained.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。