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 ;
}
 

Rank - 第二类斯特灵数的更多相关文章

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

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

  2. 斯特灵数 (Stirling数)

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

  3. hdu 2643 rank 第二类斯特林数

    题意:给定n个人,要求这n个人的所有可能排名情况,可以多个人并列(这个是关键). 题解:由于存在并列的问题,那么对于n个人,我们最多有n个排名,枚举一下1~n,累加一下就好.(注意这里是变种的斯特林数 ...

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

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

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

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

  6. Examining the Rooms - 第一类斯特灵数

    ---恢复内容开始--- 2017-08-10 20:32:37 writer:pprp 题意如下: Recently in Teddy's hometown there is a competiti ...

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

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

  8. 斯特灵(Stirling)数

    http://zh.wikipedia.org/wiki/%E6%96%AF%E7%89%B9%E7%81%B5%E6%95%B0 第一类:n个元素分成k个非空循环排列(环)的方法总数 递推式:s(n ...

  9. HDU2643(SummerTrainingDay05-P 第二类斯特林数)

    Rank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

随机推荐

  1. 设计模式——抽象工厂模式

    Abstract Factory模式,即抽象工厂模式,该模式要求Factory类为抽象的,并且里面的生产出来的产品也是抽象的! 这里需要着重说的一点就是,抽象类和抽象方法的作用--规范了子类的实现,以 ...

  2. rabbitmq延迟队列相关

    https://blog.csdn.net/qq_26656329/article/details/77891793        --------------rabbitmq queue_decla ...

  3. centos下vsftpd不能显示文件,不能创建文件及文件夹

    centos下vsftpd登录正常,但不能显示文件,不能创建文件及文件夹 这是由于selinux的机制 通过命令 [root@localhost www]# getsebool -a|grep ftp ...

  4. Bone Collector II---hdu2639(01背包求第k优解)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2639求01背包的第k大解.合并两个有序序列 选取物品i,或不选.最终的结果,是我们能在O(1)的时间内 ...

  5. Redis应用案例,查找某个值的范围(转)

    原文:https://groups.google.com/forum/#!topic/redis-db/lrYbkbxfQiQ 本文来自Redis在Google Group上的一个问题,有一位同学发贴 ...

  6. oracle入门(8)——实战:支持可变长参数、多种条件、多个参数排序、分页的存储过程查询组件

    [本文介绍] 学了好几天,由于项目需要,忙活了两天,写出了个小组件,不过现在还只能支持单表操作.也没考虑算法上的优化,查询速度要比hibernate只快了一点点,可能是不涉及多表查询的缘故吧,多表的情 ...

  7. mxGraph画图区域使用鼠标滚轮实现放大/缩小

    // 重写鼠标滚轮事件 mxEvent.addMouseWheelListener = function (funct) { } // 添加初次载入事件 window.onload = functio ...

  8. 004-Shell 基本运算符、算术运算符、关系运算符、布尔运算符、辑运算符、字符串运算符、文件测试运算符

    一.概述 Shell 和其他编程语言一样,支持多种运算符,包括: 算数运算符 关系运算符 布尔运算符 字符串运算符 文件测试运算符 二.算术运算符 原生bash不支持简单的数学运算,但是可以通过其他命 ...

  9. 使用Robomongo连接数据库不成功:没有启动MongoDB

    启动MongoDB ➜ ~ mongod --07T16:: I CONTROL [initandlisten] MongoDB starting : pid= port= dbpath=/data/ ...

  10. linux去掉文件行尾的^M

    在Linux下使用vi来查看一些在Windows下创建的文本文件,有时会发现在行尾有一些“^M”.这种文件在执行时会报错bash: ./startserver.sh: /bin/sh^M: bad i ...