CF913F.Strongly Connected Tournament

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a chess tournament in All-Right-City. n players were invited to take part in the competition. The tournament is held by the following rules:

  1. Initially, each player plays one game with every other player. There are no ties;
  2. After that, the organizers build a complete directed graph with players as vertices. For every pair of players there is exactly one directed edge between them: the winner of their game is the startpoint of this edge and the loser is the endpoint;
  3. After that, the organizers build a condensation of this graph. The condensation of this graph is an acyclic complete graph, therefore it has the only Hamiltonian path which consists of strongly connected components of initial graph _A_1 → _A_2 → ... → A__k.
  4. The players from the first component _A_1 are placed on the first places, the players from the component _A_2 are placed on the next places, and so on.
  5. To determine exact place of each player in a strongly connected component, all the procedures from 1 to 5 are repeated recursively inside each component, i.e. for every i = 1, 2, ..., k players from the component A__i play games with each other again, and so on;
  6. If a component consists of a single player, then he has no more rivals, his place is already determined and the process stops.

The players are enumerated with integers from 1 to n. The enumeration was made using results of a previous tournament. It is known that player i wins player j (i < j) with probability p.

You need to help to organize the tournament. Find the expected value of total number of games played by all the players.

It can be shown that the answer can be represented as , where P and Q are coprime integers and . Print the value of P·Q - 1 modulo 998244353.

If you are not familiar with any of the terms above, you can read about them here.

全对城正在举办一场国际象棋锦标赛,共邀请了 $ n $ 名选手参赛。比赛按如下规则进行:

  1. 初始阶段,每名选手需与其他所有选手各进行一场比赛,且不存在平局;
  2. 随后,主办方以选手为顶点构建一个完全有向图:对任意两名选手,其间恰有一条有向边,该边起点为二者比赛的胜者,终点为败者;
  3. 接着,主办方对该有向图求其缩点图(condensation)。该缩点图是一个无环的完全有向图,因此它存在唯一的哈密顿路径,形式为 $ A_1 \to A_2 \to \dots \to A_k $,其中每个 $ A_i $ 是原图的一个强连通分量;
  4. 将第一强连通分量 $ A_1 $ 中的所有选手排在前 个名次上,第二强连通分量 $ A_2 $ 中的选手排在接下来的 个名次上,依此类推;
  5. 为确定每个强连通分量内部各选手的精确名次,需在每个分量内递归地重复步骤 1 至 5:即对每个 $ i = 1, 2, \dots, k $,令分量 $ A_i $ 中的选手彼此再进行一轮完整循环赛,依此类推;
  6. 若某强连通分量仅含一名选手,则其已无对手,名次已最终确定,递归过程终止。

选手编号为 $ 1 $ 至 $ n $ 的整数,编号依据上届锦标赛结果确定。已知当 $ i < j $ 时,选手 $ i $ 击败选手 $ j $ 的概率为 $ p $。

你需要协助组织本次锦标赛。请计算所有选手总共进行的比赛场数的期望值。

可以证明,该答案可表示为 ,其中 $ P $ 与 $ Q $ 为互质整数,且 。请输出 $ P \cdot Q^{-1} \bmod 998244353 $ 的值。

若你不熟悉上述任一术语,可参阅 此处。

输入格式

The first line of input contains a single integer n (2 ≤ n ≤ 2000) — the number of players.

The second line contains two integers a and b (1 ≤ a < b ≤ 100) — the numerator and the denominator of fraction .

输入的第一行包含一个整数 $ n (( 2 \leq n \leq 2000 $)—— 表示玩家的数量。

第二行包含两个整数 $ a $ 和 $ b (( 1 \leq a < b \leq 100 $)—— 分别为分数 的分子与分母。

输出格式

In the only line print the expected value of total number of games played by all the players. Print the answer using the format above.

在唯一的一行中输出所有玩家总共进行的游戏局数的期望值。请按上述格式输出答案。

输入输出样例

  • 输入#1

    3
    1 2

    输出#1

    4
  • 输入#2

    3
    4 6

    输出#2

    142606340
  • 输入#3

    4
    1 2

    输出#3

    598946623

说明/提示

In the first example the expected value is 4.

In the second example the expected value is .

In the third example the expected value is .

在第一个例子中,期望值为 4。

在第二个例子中,期望值为 。

在第三个例子中,期望值为 。

输入解题思路,AI测评打分。不知道怎么写?

首页