# 【Puzzle】选票盒

|

【对算法，数学，计算机感兴趣的同学，欢迎关注我哈，阅读更多原创文章】

# 问题

## The-Ballot-Box

In an election, two candidates, Albert and Benjamin, have in a ballot box a and b votes respectively with a>b
Ballots are randomly drawn and tallied
What is the chance that at least once after the first tally, the candidates have the same number of tallies?

# 思路参考

## dp[i][j] 的边界值

• (1) i = 0 且 j = 0

• (2) i = 0

• (3) j = 0

## dp[i][j] 的转移方程

• (1) 下一次抽出的是 A 的选票

• (2) 下一次抽出的是 B 的选票

Python 代码如下

Share