Poll question Two

Source: Internet
Author: User

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&LT;=J) Break; -         } -     } -printf"%lld", F[m][n]); +     //System ("pause"); -     return 0; +}
Poll question two

Poll question Two

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.