| Question Description |
Ouyangwen and Yi等 campaign chairman, Wangliangsen responsible for recount, altogether M+n Zhang, the result Ouyangwen win, known Ouyangwen and Yi等 respectively get M ticket and N ticket (m>n). Now, please calculate how many Ouyangwen the number of votes in the recount process is always more than the number of yi等 votes. |
| Input |
| One row, including two numbers, M and N, respectively |
| Output |
| A number that represents the number of scenarios that meet the requirements of the topic. |
| Input example |
| 5 3 |
| Output example |
| 14 |
| Other Notes |
| Data range: 1 <= m,n < 100. |
|
Voting issue one of the upgraded version! The main reason is that the scope of the data is getting bigger, so Dfs is already confused.
Dynamic planning is a faster approach.
(Sample Analysis)
1 0
-----
2 0
-----
2 1 (3 0)
-----
3 1 (4 0)
-----
4 1,3 2 (5 0)
-----
5 1,4 2
-----
5 2,4 3
-----
5 3
***************************
1#include <iostream>2 3 using namespacestd;4 Long Longf[101][101];//recount per round, f[Ouyangwen current votes [Yi等 current votes], current total number of scenarios5 intMain ()6 {7 Long LongM,n;8scanf"%lld%lld",&m,&n);9f[1][0]=1;//Likewise, the first vote must be given to OuyangwenTen for(intI=1; i<=m;i++) One { A for(intj=0; j<=n;j++) - { - if(I>j && (i!=1|| j!=0)) f[i][j]=f[i-1][j]+f[i][j-1];//to reach the current number of votes, either add a vote to Ouyangwen, or add a vote to Yi等. the Else if(I<=J) Break; - } - } -printf"%lld", F[m][n]); + //System ("pause"); - return 0; +}Poll question two
Poll question Two