首页 > 其他分享 >[COMP2121] Bertrand's Ballot Problem

[COMP2121] Bertrand's Ballot Problem

时间:2022-10-28 12:57:13浏览次数:59  
标签:votes set frac sequence Bertrand COMP2121 sequences Problem first

Description

Suppose there are $x$ votes for $A$ and $y$ notes for $B$, and $x>y$. How many sequences are there of revealing the votes such that the number votes for $A$ is always strictly bigger than that for $B$?

 

Solution (by reflection)

First, we draw the process of revealing the votes using line charts (the horizontal axis represents the number of votes revealed, the vertical axis represents $x_cur-y_cur$):

g1

Define the grand set $\Omega$ to be the set of sequences that starts from $0$ and ends at $x-y$. A valid sequence drawn in such a way should never touch the horizontal axis. 

Note that the first vote must be a "+1". Let $A$ denote the set of sequences whose first element is "+1" and $B$ denote the set of sequences whose first element is "+1" but not valid (touches 0 at some point). Then the answer would be

$$|A| - |B|$$

It is easy to see that

$$|A| = \frac{(x+y-1)!}{(x-1)!y!}$$

Now use the technique of bijection to compute $|B|$, i.e. find an easily-computable set $C$ such that sequences in $B$ and $C$ has an one-to-one relation.

We attempt to find $C$ in such a way: for every sequence in $B$, reflect the prefix before the line first touches 0 with respect to the horizontal axis to get a sequence in $C$:

g2

By observing, we try to define $C$ to be the set of sequences whose first element is "-1" (and ends at $x-y$). Then, according to the mapping, different sequences in $B$ will result in different sequences in $C$, so the mapping is injective. Also, for every sequence in $C$, there exists a sequence in $B$ which is obtained by reflecting $C$'s prefix before first touching 0 (such prefix always exists because it goes from $-1$ to $x-y$), so the mapping is bijective. Therefore, we successfully find the $C$ we want.

Now compute $|C|$. Suppose in the next $x+y-1$ steps, there are $a$ "+1"s and $b$ "-1"s, then:

$$\left\{\begin{matrix}a+b=x+y-1 \\-1+a-b=x-y\end{matrix}\right. \Rightarrow \left\{\begin{matrix}a=x \\b=y-1\end{matrix}\right.$$

Thus,

$$|C|=\frac{(x+y-1)!}{x!(y-1)!}$$

Alternatively, $C$ is the complement of $A$:

$$|C|=|\Omega|-|A|=\frac{(x+y)!}{x!y!}-\frac{(x+y-1)!}{(x-1)!y!}=\frac{(x+y-1)!}{x!(y-1)!}$$

Finally, we can compute the answer:

$$|A|-|B|=|A|-|C|=\frac{(x-y)(x+y-1)!}{x!y!}$$

 

 

标签:votes,set,frac,sequence,Bertrand,COMP2121,sequences,Problem,first
From: https://www.cnblogs.com/ms-qwq/p/16835716.html

相关文章

  • Problem In Developing
    写了一段代码后发现无法通过测试思路1:首先review这段代码,思考可能会出现什么问题需要及时提交commit思路2:回退代码后重写思路3:找到错误信息,调试bug......
  • D. Problem with Random Tests
    传送门题意:给出一个字符串,然后,从这个字符串中取两个子串s1,s2,要求两个字符串的或最大思路:首先,先去s1从第一个非0开始取整段,记录第一个非0的位置为p1,因为或位数......
  • [React] useEffect - problem: dependency is Object
    Let'ssaywehaveasimpleapplooklikethis:import{useEffect,useState}from"react";functionuseFetch(config){console.log("useFetchcall");cons......
  • 关于 problem.conf
    基本设置problem.conf中一行只能含有一个设置(不然可能会出现奇怪的错误?)use_builtin_judger大多数题的problem.conf里都要有use_builtin_judgeron这句话,这表示您需......
  • 中国(北方)大学生程序设计训练赛(第一周)(Problem E: Water Problem-矩阵快速幂)
    已知f(1),f(2),n,f(n+1)=f(n)+f(n-1)+sin(n*Pi/2),(n>=2)求f(n)矩阵快速幂,周期乘4个矩阵#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#incl......
  • BZOJ 2302([HAOI2011]Problem c-组合数学)
    Description给n个人安排座位,先给每个人一个1~n的编号,设第i个人的编号为ai(不同人的编号可以相同),接着从第一个人开始,大家依次入座,第i个人来了以后尝试坐到ai,如果ai被占据了,就......
  • ARC139F Many Xor Optimization Problems
    题意:给定\(n,m\),求\(n\)个\([0,2^m)\)的数的最大异或和的和。瞎扯:考虑线性基,考虑消元后的,显然唯一,最大异或和为基内所有数的异或和。考虑大小为\(k\)的基方案数为......
  • D. Problem with Random Tests
    D.ProblemwithRandomTestsYouaregivenastring$s$consistingof$n$characters.Eachcharacterof$s$iseither$0$or$1$.Asubstringof$s$isaconti......
  • [COMP2121] Discrete Mathematics - Question on Function
    DescriptionLet$A$beafiniteset,andlet$F(A)$bethesetofallfunctionsfrom$A$toitself.Considertherelation$R$on$F(A)$definedby$fRg$ifand......
  • 题解 For Problem. 完全参差序列
    Problem.完全参差序列题目背景2022年,南京师范大学迎来了120周年校庆,值此120周年校庆筹备工作全面启动之际,学校诚邀海内外校友、社会贤达、各界人士壬寅中秋相聚金陵,......