[ACM] SDUT 2883 Hearthstone II (第二类Stiring数)
来源:互联网 发布:建军大业知乎 编辑:程序博客网 时间:2024/06/04 18:09
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张桌子,每张桌子至少被用一次,桌子不同,问一共有多少种安排方法。
也就是把n个元素分到m个非空且不可区分的集合中去。第二类Stiring数 s(n,m)意思是把n个元素分到m个非空且不可区分的集合中去。本题集合(桌子)是可区分的,那么答案为
m! *s(n,m).
知识详解见:http://blog.csdn.net/sr_19930829/article/details/40888349
代码:
#include <iostream> #include <string.h> using namespace std; const int maxn=102; const int mod=1e9+7; typedef long long ll; ll s[maxn][maxn]; int n, m; void init() { memset(s,0,sizeof(s)); s[1][1]=1; for(int i=2;i<=100;i++) for(int j=1;j<=i;j++) { s[i][j]=s[i-1][j-1]+j*s[i-1][j]; if(s[i][j]>=mod) s[i][j]%=mod; } } ll solve(int n,int m) { ll ans=s[n][m]; for(int i=2;i<=m;i++) { ans*=i; if(ans>=mod) ans%=mod; } return ans; } int main() { init(); while(cin>>n>>m) { cout<<solve(n,m)<<endl; } return 0; }
0 0
- [ACM] SDUT 2883 Hearthstone II (第二类Stiring数)
- sdut 2883 Hearthstone II (第二类Stiring数)
- 山东省第五届ACM省赛题——Hearthstone II(第二类Stiring数)
- SDUT:2883 Hearthstone II(第二类Stirling数)
- 山东省第五届ACM大学生程序设计竞赛-Hearthstone II(组合数学-第二类Stirling数)
- 2014年山东省第五届ACM大学生程序设计竞赛--Hearthstone II(第一类Stirling数)
- SDUT 2883 Hearthstone II【打表找规律/Dp思维】
- 第五届山东省ACM Hearthstone II(Dp)
- 山东省第五届ACM大学生程序设计竞赛 Hearthstone II 组合数学 Stirling数
- 第一类stiring数
- 2014山东省第五届ACM省赛 Hearthstone II
- 第五届ACM大学生程序设计竞赛:Hearthstone II
- 2014山东省第五届ACM省赛 Hearthstone II
- ACM 删数问题 SDUT 2072
- Sdut 2165 Crack Mathmen(数论)(山东省ACM第二届省赛E 题)
- Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)
- SDUT 2165 Crack Mathmen(快速幂)山东省第二届ACM大学生程序设计竞赛
- sdut 2161 Simple Game(山东省第二届acm省赛A题)(博弈论Nim+Bush?)
- POJ1502(Dijkstra)
- HomeworldSDL终于在Linux虚拟机上跑起来了
- 利用函数求阶乘
- C++内存管理与指针的使用
- zoj1002(Fire Net)
- [ACM] SDUT 2883 Hearthstone II (第二类Stiring数)
- 'Could not load NIB in bundle: 'NSBundle解决办法
- 有关lua,luci的介绍
- HDOJ1019最大公约与最小公倍
- uva Happy Number
- c++内存管理机制
- js中的继承
- Schema的快速入门
- 十一周四个数的最大公约数