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

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. python基础-第七篇-7.3反射

    定义 反射是根据字符串的形式去对操作其成员 了解反射前,我先看看内置方法__import__,还记得这个内置方法吗? __import__  用于以字符串的形式导入模块 inp = input('请输 ...

  2. 解决Bat脚本中包含中文,运行乱码

    bat文件右键用“编辑” 打开, 另存为时,UTF-8保存为ANSI 格式.即可解决运行时乱码问题.

  3. Websocket - Websocket原理(握手、解密、加密)、基于Python实现简单示例

    一.Websocket原理(握手.解密.加密) WebSocket协议是基于TCP的一种新的协议.WebSocket最初在HTML5规范中被引用为TCP连接,作为基于TCP的套接字API的占位符.它实 ...

  4. 20165324《Java程序设计》第一周

    20165324<Java程序设计>第一周学习总结 教材学习内容总结 第一章:Java入门 重点一.编写Java程序 第一步编写源文件,(注:第一步中Java严格区分大小写:Java源文件 ...

  5. memento模式

    参考资料 • 维基百科:https://en.wikipedia.org/wiki/Memento_pattern • 百度百科:http://baike.baidu.com/link?url=ZQZ ...

  6. linux文件修改管理

    Linux文件系统的层次结构 Linux文件系统的树状结构 目录是什么 顶层根目录的表示 文件系统中的两个特殊目录 Linux系统中的一些重要的目录 bin目录 sbin目录 家目录 dev目录 et ...

  7. 【转】使用DataConnectionDialog在运行时设置数据源连接字符串

    介绍: DataConnectionDialog 类: 打开“数据连接”对话框,获取用户选择的数据连接信息. 命名空间为:Microsoft.Data.ConnectionUI 所在程序集:Micro ...

  8. javascript 基本数据类型、引用数据类型

    阅读目录 数据类型 两种访问方式 两种类型复制 函数参数的传递 两种变量类型检测 回到目录   数据类型 1.   ECMAScript变量包含两种不同类型的值:基本类型值.引用类型值: 2.   基 ...

  9. SQL统计信息解释

    [SQL基础]统计信息解释 在平时优化SQL的时候,最长用的就是:SET STATISTICS ON,它可以用来查看我们写的查询语句到底性能如何,不过,究竟这个性能的指标是怎么样的呢?首先需要明白的, ...

  10. Django学习笔记之uWSGI详解

    WSGI是什么? WSGI,全称 Web Server Gateway Interface,或者 Python Web Server Gateway Interface ,是为 Python 语言定义 ...