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

最新文章

  1. SharePoint2016母版页的直接依赖项的数目限制超过10的限制解决方案Direct Dependencies Limit with Master page User Controls
  2. 开发便于运维的Windows服务
  3. WinForm窗体代码结构优化
  4. SharpDevelop的亮点&mdash;优化提示
  5. ubuntu apache开启重写模块
  6. JAVA坏境变量中的JAVA_HOME path classpath 的设置与作用。
  7. 利用MariaDB Galera Cluster实现mariadb的多主复制
  8. iOS--NSAttributedString使用介绍
  9. Eclipse+Java+OpenCV246人脸识别
  10. ASP.NET DataTable的操作大全
  11. 应届毕业生如何通过学习Linux系统选择一份高薪职业
  12. linux利用ssh远程执行多台机器执行同样的命令
  13. JAVA注释--2019-04-28
  14. 阿里云 部署dashboard
  15. python使用gevent实现并发下载器
  16. Django 通过 mongoengine 连接 MongoDB 进而使用orm进行CRUD
  17. Linux期末复习题
  18. UNITY 的GC ALLOC到底是什么
  19. 将网址url中的参数转化为JSON格式
  20. 音频audio,加层父级

热门文章

  1. sql语句的安全性考虑
  2. git远程库与本地联系报错:fatal: Not a git repository (or any of the parent directories): .git
  3. CF #301 E:Infinite Inversions(逆序数,树状数组)
  4. Python的subprocess模块(一)
  5. Django内置form表单和ajax制作注册页面
  6. Jersey 出现415 MediaType is not supported问题的原因
  7. C#建WindowForm调用R可视化
  8. DOM扩展学习笔记
  9. 安装pip环境以及pip常用命令使用
  10. Myeclipse中is missing required source folder问题的解决