SDUT 2883 Hearthstone II【打表找规律/Dp思维】

Hearthstone II

Time Limit: 2000MS  Memory Limit: 65536KB
Problem Description
The new season has begun, you have n competitions and m well prepared decks during the new season. Each competition you could use any deck you want, but each of the decks must be used at least once. Now you wonder how many ways are there to plan the season — to decide for each competition which deck you are going to used. The number can be very huge, mod it with 10^9 + 7.
 
Input
The input file contains several test cases, one line for each case contains two integer numbers n and m (1 ≤ m ≤ n ≤ 100).
 
Output
One line for each case, output one number — the number of ways.
Example Input
3 2
100 25
Example Output
6
354076161
Hint
 
Author
2014年山东省第五届ACM大学生程序设计竞赛

题目大意:

给你N场比赛,有M张桌子,一场比赛选择一张桌子使用,需要保证N场比赛之后,所有的桌子都被这个队至少使用了一次。

问一共有多少种方案数 。


思路:


遇事不决先打表,打表找到规律:ans【i】【j】=j*(ans【i-1】【j】+ans【i-1】【j-1】)


Ac代码:

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LL long long int
int main()
{
    LL ans[150][150];
    memset(ans,0,sizeof(ans));
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=i;j++)
        {
            if(j==1)
            {
                ans[i][j]=1;
                continue;
            }
            ans[i][j]=(ans[i-1][j]+ans[i-1][j-1])*j;
            ans[i][j]%=mod;
        }
    }
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        printf("%lld\n",ans[n][m]);
    }
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值