Examining the Rooms - 第一类斯特灵数
---恢复内容开始---
2017-08-10 20:32:37
writer:pprp
题意如下:
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 ;
}
Examining the Rooms - 第一类斯特灵数的更多相关文章
- HDU 3625 Examining the Rooms【第一类斯特灵数】
<题目链接> <转载于 >>> > 题目大意:有n个锁着的房间和对应n扇门的n把钥匙,每个房间内有一把钥匙.你可以破坏一扇门,取出其中的钥匙,然后用取出钥匙打 ...
- counting the buildings - 第一类斯特灵数
2017-08-10 21:10:08 writer:pprp //TLE #include <iostream> #include <cstdio> #include < ...
- [HDU 3625]Examining the Rooms (第一类斯特林数)
[HDU 3625]Examining the Rooms (第一类斯特林数) 题面 有n个房间,每个房间有一个钥匙,钥匙等概率的出现在n个房间内,每个房间中只会出现且仅出现一个钥匙.你能炸开门k次, ...
- cf932E. Team Work(第二类斯特灵数 组合数)
题意 题目链接 Sol 这篇题解写的非常详细 首先要知道第二类斯特灵数的一个性质 \[m^n = \sum_{i = 0}^m C_{n}^i S(n, i) i!\] 证明可以考虑组合意义:\(m^ ...
- Examining the Rooms(dp,斯特灵数)
Examining the Rooms Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 3625 Examining the Rooms —— 第一类斯特林数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3625 学习斯特林数:https://blog.csdn.net/qq_33229466/article/d ...
- hdu 3625 Examining the Rooms——第一类斯特林数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3625 n^2 求斯特林数就行.要减去的就是1号钥匙在1号房间的方案,即 s[ n-1 ][ m-1] . ...
- 斯特灵数 (Stirling数)
@维基百科 在组合数学,Stirling数可指两类数,都是由18世纪数学家James Stirling提出的. 第一类 s(4,2)=11 第一类Stirling数是有正负的,其绝对值是个元素的项目分 ...
- Rank - 第二类斯特灵数
2017-08-10 20:32:37 writer:pprp 题意如下: Recently in Teddy's hometown there is a competition named &quo ...
随机推荐
- C++应该被看成是个语言集合——四种语言(C语言,OO语言,泛型语言,STL)
至少有三种语言: 一,C++ is C 二,C++ is an OO language 三,C++ is a genetic programming language 有的童鞋觉得难,可能是没有看清楚 ...
- virtio前端驱动详解
2016-11-08 前段时间大致整理了下virtIO后端驱动的工作模式以及原理,今天就从前端驱动的角度描述下目前Linux内核代码中的virtIO驱动是如何配合后端进行工作的. 注:本节代码参考Li ...
- sVIrt概述
sVirt概述 前面已经对seLInux的基本原理做了分析,seLinux主要就是基于主体和客体的安全上下文,进行访问决策.那么安全上下文是不是又可以理解为一个标签呢? 基于以上seLInux的特性, ...
- git子模块submodule
添加submodule: git submodule add 子模块git地址 把这个module放置的文件夹(这个文件夹须事先不存在) git submodule add http://xxx.x ...
- Telnet命令参考手册
Dubbo2.0.5以上版本服务提供端口支持telnet命令,使用如: telnet localhost 20880 或者: echo status | nc -i 1 localhost 20880 ...
- Ubuntu apt-get更换阿里云源
sudo vim /etc/apt/sources.list deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe ...
- PAT 1049 Counting Ones [难]
1049 Counting Ones (30 分) The task is simple: given any positive integer N, you are supposed to coun ...
- .htaccees什么鬼?怎么用?
.htaccess文件全称Hypertext Access(超文本入口).提供了针对目录改变配置的方法, 即,在一个特定的文档目录中放置一个包含一个或多个指令的文件, 以作用于此目录及其所有子目录.作 ...
- 使用DAO工厂创建实现类对象
首先分析DAO模式中的每一部分 VO(对象实体):这个类成员变量与数据库中每个字段一一对应,同时提供了相应是set和get方法来设置或取得数值.这个类一般是通过IDE自动生成的 DAO(数据访问接口) ...
- SqlHelper简单实现(通过Expression和反射)10.使用方式
以下是整个SqlHelper的Demo: public Result<List<ArticleDTO>> GetIndexArticleList(int count, int ...