Hrbust 2210 A Wonderful Concert【Dp】水题

A Wonderful Concert
Time Limit: 1000 MSMemory Limit: 32768 K
Total Submit: 7(5 users)Total Accepted: 2(2 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

题目大意:


一个商店一开始没有零钱,一张票50块钱,我们有n个人有50块钱,m个人有100块钱,问我们可以有多少种分配方案,使得所有100块钱的同学买票的同时会被找零。


思路:


设定Dp【i】【j】表示现在有i个50块钱j个100块钱的顾客的排列方案。


那么有:Dp【i】【j】=Dp【i-1】【j】+Dp【i】【j-1】;


Ac代码:

#include<stdio.h>
#include<string.h>
using namespace std;
int dp[1005][1005];
void init()
{
    dp[0][0]=1;
    for(int i=0;i<=1000;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(i==0&&j==0)continue;
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=1000000007;
        }
    }
}
int main()
{
    init();
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        printf("%d\n",dp[n][m]%1000000007);
    }
}









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值