2014山东省第五届ACM省赛 Hearthstone II
2016-03-28 18:01
344 查看
Hearthstone II
Time Limit: 2000MS Memory limit: 65536K
题目描述
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.
输入
The input file contains several test cases, one line for each case contains two integer numbers n and m (1 ≤ m ≤ n ≤ 100).输出
One line for each case, output one number — the number of ways.示例输入
3 2 100 25
示例输出
6 354076161
提示
来源
2014年山东省第五届ACM大学生程序设计竞赛题意:n次比赛,有m个场地,求每个场地至少用一次的方案数。
d[i][j]表示前i次比赛用了j个场地的方案数。
d[i][j] = d[i-1][j] * j + d[i-1][j-1] * (m-j+1)
include <string.h> #include <cmath> using namespace std; #define mod 1000000007 long long int d[110][110]; int main() { int n,m; while(cin>>n>>m) { memset(d,0,sizeof(d)); d[0][0]=1; for(int i=1; i<=n; i++) for(int j=1; j<=min(m,i); j++) { d[i][j]=(d[i-1][j]*j%mod+d[i-1][j-1]*(m-j+1)%mod)%mod; } cout<<d [m]<<endl; } return 0; }
相关文章推荐
- HTTP Header 详解
- IOS-协议的理解和倒计时demo
- git clone --recursive 参数在Jenkins里的配置实现
- 支付宝集成问题
- iOS,如何模仿一个App
- 汉诺塔问题
- Mac系统如何清理
- linux tcpdump抓包命令
- 找出给定字符串中数字字符 (即’0’—‘9’这10个数字)的个数
- IOS持续集成-详细介绍-2016
- MAC上配置阿里云PHP开发环境
- ASP.NET Web API——选择Web API还是WCF
- 今天你将废纸篓清理干净了吗
- Android AIDL简要介绍及使用
- Android:如何给ScrollView添加滑块滚动条
- Could not find Developer Disk Image 真机测试
- C++笔试面试题
- 微信支付成功后推荐关注栏目规则:
- 9.ARM汇编指令集概述
- 解析su,su -,sudo的区别