2014山东省第五届ACM省赛 Hearthstone II
来源:互联网 发布:淘宝绣花针 编辑:程序博客网 时间:2024/05/16 17:39
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 2100 25
示例输出
6354076161
提示
来源
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[n][m]<<endl; } return 0; }
0 0
- 2014山东省第五届ACM省赛 Hearthstone II
- 2014山东省第五届ACM省赛 Hearthstone II
- 第五届山东省ACM Hearthstone II(Dp)
- 2014年山东省第五届ACM大学生程序设计竞赛--Hearthstone II(第一类Stirling数)
- 山东省第五届ACM大学生程序设计竞赛 Hearthstone II 组合数学 Stirling数
- 山东省第五届ACM省赛题——Hearthstone II(第二类Stiring数)
- 山东省第五届ACM大学生程序设计竞赛-Hearthstone II(组合数学-第二类Stirling数)
- 第五届ACM大学生程序设计竞赛:Hearthstone II
- 2014山东省第五届ACM省赛
- 2014山东省第五届ACM省赛 angry_birds_again_and_again
- 2014山东省第五届ACM省赛 Factorial
- 2014山东省第五届ACM省赛 Circle
- 2014山东省第五届ACM省赛 angry_birds_again_and_again
- 2014山东省第五届ACM省赛 Circle
- 2014山东省第五届ACM省赛 Weighted Median
- 2014山东省第五届ACM省赛 Full Binary Tree
- 2014山东省第五届ACM省赛 Devour Magic
- 2014山东省第五届ACM省赛 Full Binary Tree
- Mac系统如何清理
- iOS开发之如何跳到系统设置里的各种设置界面
- 使用dialog对话框时第二次点击报错 IllegalStateException
- iOS,如何模仿一个App
- IOS-协议的理解和倒计时demo
- 2014山东省第五届ACM省赛 Hearthstone II
- BeanUtils使用总结 setProperties
- JSP隐式对象
- 不分组求和(Linq、存储过程)
- 支付宝集成问题
- Android 高德地图点击地图获取经纬度
- 递归实现字符串反转
- MFC提供的集合类CStringArray类和CPtrArray类
- mysql note