A Wonderful Concert HRBUST - 2210

A Wonderful Concert
Time Limit: 1000 MSMemory Limit: 32768 K
Total Submit: 20(16 users)Total Accepted: 6(6 users)Rating: Special Judge: No
Description

Recently ,a famous singer will come to our school ,and he is going   to host a concert in the assembly hall .Because of the high popularity of this singer ,many student have great willing to come to this concert.

As you know , this concert’s ticket price is 50 yuan .Some day ,there are m students who only have 50 yuan and n students who only have 100 yuan coming to buy ticket . But a horrible thing happened ,the ticket seller don’t have any change .

Now , this is your show time .Please tell the ticket seller the kind of queuing ways that all people can buy ticket without problem .Obviously ,everyone can only buy one ticket .


Input

The input file contains multiple test cases.

For each test case: it contains two integer m and n .

You should proceed to the end of file.

Hint:

1 <= <= m <= 1000

Output

For each test case, output the total ways.Because this number may be too large ,you just output the values mod 1000000007.

Sample Input
1 1
2 1
2 2

Sample Output
1
2
2

Source
CPC23 2014-6
Author
Zhou Ben

题意:有m个持有50元的人,n个持有100元的人.每张门票50元,在当前没有零钱的情况下,有多少种方案数可以实现票全部卖完,且一人一张

思路:dp[i][j]定义为有i个50元,j个100元的方案数

对于第i+j个人,有dp[i][j]=dp[i-1][j]+dp[i][j-1]
#include <stdio.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define bug1 cout <<"bug1"<<endl
#define bug2 cout <<"bug2"<<endl
#define bug3 cout <<"bug3"<<endl
using namespace std;
typedef long long ll;


const int MAX_N=1e3+3;

int dp[MAX_N][MAX_N];

void fun(){
    for(int i=1;i<=1000;i++)    dp[i][1]=i;
    for(int j=1;j<=1000;j++)    dp[1][j]=0;
    dp[1][1]=1;
    for(int i=2;i<=1000;i++){
        for(int j=2;j<=i;j++)    dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
    }
}

int main(void){
        fun();
        int n,m;
        /*for(int i=1;i<=10;i++){
            for(int j=1;j<=10;j++)    printf("%5d ",dp[i][j]);

            puts("");
        }*/
        while(~scanf("%d%d",&m,&n)){
            cout << dp[m][n]<<endl;
        }
    }
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值