---恢复内容开始---

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 

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 - 第一类斯特灵数的更多相关文章

  1. HDU 3625 Examining the Rooms【第一类斯特灵数】

    <题目链接> <转载于 >>> > 题目大意:有n个锁着的房间和对应n扇门的n把钥匙,每个房间内有一把钥匙.你可以破坏一扇门,取出其中的钥匙,然后用取出钥匙打 ...

  2. counting the buildings - 第一类斯特灵数

    2017-08-10 21:10:08 writer:pprp //TLE #include <iostream> #include <cstdio> #include < ...

  3. [HDU 3625]Examining the Rooms (第一类斯特林数)

    [HDU 3625]Examining the Rooms (第一类斯特林数) 题面 有n个房间,每个房间有一个钥匙,钥匙等概率的出现在n个房间内,每个房间中只会出现且仅出现一个钥匙.你能炸开门k次, ...

  4. cf932E. Team Work(第二类斯特灵数 组合数)

    题意 题目链接 Sol 这篇题解写的非常详细 首先要知道第二类斯特灵数的一个性质 \[m^n = \sum_{i = 0}^m C_{n}^i S(n, i) i!\] 证明可以考虑组合意义:\(m^ ...

  5. Examining the Rooms(dp,斯特灵数)

    Examining the Rooms Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. hdu 3625 Examining the Rooms —— 第一类斯特林数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3625 学习斯特林数:https://blog.csdn.net/qq_33229466/article/d ...

  7. hdu 3625 Examining the Rooms——第一类斯特林数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3625 n^2 求斯特林数就行.要减去的就是1号钥匙在1号房间的方案,即 s[ n-1 ][ m-1] . ...

  8. 斯特灵数 (Stirling数)

    @维基百科 在组合数学,Stirling数可指两类数,都是由18世纪数学家James Stirling提出的. 第一类 s(4,2)=11 第一类Stirling数是有正负的,其绝对值是个元素的项目分 ...

  9. Rank - 第二类斯特灵数

    2017-08-10 20:32:37 writer:pprp 题意如下: Recently in Teddy's hometown there is a competition named &quo ...

随机推荐

  1. beego

    https://www.kancloud.cn/hello123/beego/126087

  2. Ansible安装过程中常遇到的错误(FAQ)

    1.安装完成后允许命令报错 Traceback (most recent call last): File , in <module> (runner, results) = cli.ru ...

  3. ShuffleNet

    ShuffleNet (An Extremely Efficient Convolutional Neural Network for Mobile Devices) —— Face++ shuffl ...

  4. python 递归深度优先搜索与广度优先搜索算法模拟实现

    一.递归原理小案例分析 (1)# 概述 递归:即一个函数调用了自身,即实现了递归 凡是循环能做到的事,递归一般都能做到! (2)# 写递归的过程 1.写出临界条件2.找出这一次和上一次关系3.假设当前 ...

  5. Linux ls命令

    ls:即列表List的意思,用来列出目录下的文件用来列出给定目录下的文件,参数为空默认列出当前目录下的文件. 用法是:ls [选项] [目录] 常用的选项有 -a, –all 列出目录下的所有文件,包 ...

  6. C# 预定义语言

    官网: https://msdn.microsoft.com/zh-cn/library/88td0y52.aspx [Conditional("DEBUG")] 作为预处理中的一 ...

  7. 15.遇到window leaked的解决方法

    遇到这个可能是android:configChanges没有配置好 可以试试配置为这个 mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navig ...

  8. LoadJS

    LoadJS是一个微小的异步加载器为现代浏览器(711字节). https://github.com/muicss/loadjs 介绍 LoadJS是一个微小的异步加载库的现代浏览器(IE9 +). ...

  9. Using Bluetooth LE with Go (Golang)

    Using Bluetooth LE with Go (Golang)  Gatt is a Go package, which provides developers to create BLE a ...

  10. notepade++使用

    Notepad++也可以实现双视图/双窗口对比显示,目前最新版本(6.32)只能支持双视图显示,而且只能支持左右视图,希望后续版本能得到改进. 我们打开两个需要对比显示的源文件 默认的情况下是分成了两 ...