QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: jiangly

Posted at: 2025-12-14 07:07:08

Last updated: 2025-12-14 07:07:12

Back to Problem

题解

获胜的局面存在恰好一张牌 $x_i$,使得其之前的和 $S\le a$,且 $a< S+x_i\le b$。注意到这种情形的概率只与前面的牌数有关,再加上记录 $a$,可以在 $O(n^2a)$ 的时间内 DP 求出每种情况的方案数。

枚举上述的 $x_i$,撤销掉它在 DP 中产生的贡献,然后枚举前面的牌数以及总和统计答案即可。总时间复杂度 $O(n^2a)$。

Comments

No comments yet.