Rank - 第二类斯特灵数
2024-08-31 05:48:02
2017-08-10 20:32:37
writer:pprp
题意如下:
Recently in Teddy's hometown there is a competition named "Cow Year Blow Cow".N competitors had took part in this competition.The competition was so intense that the rank was changing and changing.
Now the question is:
How many different ways that n competitors can rank in a competition, allowing for the possibility of ties.
as the answer will be very large,you can just output the answer MOD 20090126.
Here are the ways when N = 2:
P1 < P2
P2 < P1
P1 = P2
Now the question is:
How many different ways that n competitors can rank in a competition, allowing for the possibility of ties.
as the answer will be very large,you can just output the answer MOD 20090126.
Here are the ways when N = 2:
P1 < P2
P2 < P1
P1 = P2
InputThe first line will contain a T,then T cases followed.
each case only contain one integer N (N <= 100),indicating the number of people.OutputOne integer pey line represent the answer MOD 20090126.Sample Input
2
2
3
Sample Output
3
13
代码如下:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> #define ll long long using namespace std; const int N = ;
const int MOD = ;
ll dp[N][N], ans[N], fac[N]; void init()
{
fac[] = ;
for(int i = ; i < N; i++)
fac[i] = (fac[i-]*i)%MOD; //阶乘初始化
memset(dp, , sizeof(dp));
for(int n = ; n < N; n++)
{
dp[n][] = ;
dp[n][n] = ;
for(int k = ; k < n; k++)
{
dp[n][k] = dp[n-][k-]+k*dp[n-][k];
dp[n][k] %= MOD;
}
}
} int main()
{
int T, n;
init();
cin>>T;
while(T--)
{
cin>>n;
ll ans = ;
for(int i = ; i <= n; i++)
ans = (ans + fac[i]*dp[n][i]) % MOD;
cout<<ans<<endl;
} return ;
}
最新文章
- SharePoint2016母版页的直接依赖项的数目限制超过10的限制解决方案Direct Dependencies Limit with Master page User Controls
- 开发便于运维的Windows服务
- WinForm窗体代码结构优化
- SharpDevelop的亮点&mdash;优化提示
- ubuntu apache开启重写模块
- JAVA坏境变量中的JAVA_HOME path classpath 的设置与作用。
- 利用MariaDB Galera Cluster实现mariadb的多主复制
- iOS--NSAttributedString使用介绍
- Eclipse+Java+OpenCV246人脸识别
- ASP.NET DataTable的操作大全
- 应届毕业生如何通过学习Linux系统选择一份高薪职业
- linux利用ssh远程执行多台机器执行同样的命令
- JAVA注释--2019-04-28
- 阿里云 部署dashboard
- python使用gevent实现并发下载器
- Django 通过 mongoengine 连接 MongoDB 进而使用orm进行CRUD
- Linux期末复习题
- UNITY 的GC ALLOC到底是什么
- 将网址url中的参数转化为JSON格式
- 音频audio,加层父级
热门文章
- sql语句的安全性考虑
- git远程库与本地联系报错:fatal: Not a git repository (or any of the parent directories): .git
- CF #301 E:Infinite Inversions(逆序数,树状数组)
- Python的subprocess模块(一)
- Django内置form表单和ajax制作注册页面
- Jersey 出现415 MediaType is not supported问题的原因
- C#建WindowForm调用R可视化
- DOM扩展学习笔记
- 安装pip环境以及pip常用命令使用
- Myeclipse中is missing required source folder问题的解决