permutation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 141    Accepted Submission(s): 81

Problem Description

Permutation plays a very important role in Combinatorics. For example ,1 2 3 4 5 and 1 3 5 4 2 are both 5-permutations. As everyone's known, the number of n-permutations is n!. According to their magnitude relatives ,if we insert the sumbols "<" or ">"between every pairs of consecutive numbers of a permutations,we can get the permutations with symbols. For example,1 2 3 4 5 can be changed to 1<2<3<4<5, 1 3 5 4 2 can be changed to 1<3<5>4>2. Now it's yout task to calculate the number of n-permutations with k"<"symbol. Maybe you don't like large numbers ,so you should just geve the result mod 2009.

Input

Input may contai multiple test cases.
Each test case is a line contains two integers n and k .0<n<=100 and 0<=k<=100.
The input will terminated by EOF.

Output

The nonegative integer result mod 2009 on a line.

Sample Input

5 2

Sample Output

66

#include <iostream>

using namespace std;
const int m=2009;
int dp[110][110]; int main()
{
int n,k,i,j; //预处理
for(i=0;i<=100;i++)
{
dp[i][0]=1;
dp[i][i]=0;
}
for(i=1;i<=100;i++)
for(j=1;j<i;j++)
if(j==i-1)//k==n-1时,结果为1
dp[i][j]=1;
else//状态转移方程dp[i][j]=(j+1)*dp[i-1][j]+(i-j)*dp[i-1][j-1];
dp[i][j]=((j+1)*dp[i-1][j]%m+(i-j)*dp[i-1][j-1]%m)%m; while(cin>>n>>k)
if(k>n)//n>=k时,结果必为0
cout<<'0'<<endl;
else
cout<<dp[n][k]<<endl; return 0;
}

hdu 2583 permutation的更多相关文章

  1. hdu 2583 permutation 动态规划

    Problem Description Permutation plays a very important role in Combinatorics. For example ,1 2 3 4  ...

  2. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  3. hdu 5753 Permutation Bo 水题

    Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  4. HDU 3811 Permutation 状压dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3811 Permutation Time Limit: 6000/3000 MS (Java/Othe ...

  5. HDU 6628 permutation 1 (暴力)

    2019 杭电多校 5 1005 题目链接:HDU 6628 比赛链接:2019 Multi-University Training Contest 5 Problem Description A s ...

  6. HDU 4345 Permutation dp

    Permutation Problem Description There is an arrangement of N numbers and a permutation relation that ...

  7. hdu 5753 Permutation Bo

    这里是一个比较简单的问题:考虑每个数对和的贡献.先考虑数列两端的值,两端的摆放的值总计有2种,比如左端:0,大,小:0,小,大:有1/2的贡献度.右端同理. 中间的书总计有6种可能.小,中,大.其中有 ...

  8. 【数学】HDU 5753 Permutation Bo

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 题目大意: 两个序列h和c,h为1~n的乱序.h[0]=h[n+1]=0,[A]表示A为真则为 ...

  9. HDU 6044--Limited Permutation(搜索+组合数+逆元)

    题目链接 Problem Description As to a permutation p1,p2,⋯,pn from 1 to n, it is uncomplicated for each 1≤ ...

随机推荐

  1. jQuery的事件click

    不管是在asp.net 还是asp.net mvc中,对象的click事件是我们最常用到的一个事件,说明用户click点击一下mouse的左键,铵下并放开的事件. 今天已经是十一月份了,学习又是新的开 ...

  2. C#中this的 四种 用法

    C#中的this用法,相信大家应该有用过,但你用过几种?以下是个人总结的this几种用法,欢迎大家拍砖,废话少说,直接列出用法及相关代码. this用法1:限定被相似的名称隐藏的成员 /// < ...

  3. LODOP打印插件

    HTML代码(请先下载对应LODOP插件安装)  -    打印onclike事件CreatePrintPage()打印函数,LODOP.PREVIEW()打印预览. <div class=&q ...

  4. Winform调用QQ发信息并且开机启动 (开源)

    前言 公司CS系统需要加入启动qq从winform调用qq聊天窗口的功能,前提是需要将聊天者的QQ号码作为参数传递到函数中,一直没有搞过,正好很感兴趣,就折腾,Winform调用qq,我想肯定是需要一 ...

  5. mongodb学习4---索引

    1,mongodb的性能分析 db.active.find({id:'sdfasdf6jh67j353g346hkfgh6'}).explain('executionStats') "mil ...

  6. 测试驱动开发(TDD)的思考

    极限编程 敏捷开发是一种思想,极限编程也是一种思想,它与敏捷开发某些目标是一致的.只是实现方式不同.测试驱动开发是极限编程的一部分. 1.极限编程这个思路的来源 Kent Beck先生最早在其极限编程 ...

  7. ASP.NET Web API默认支持的媒体类型(SupportedMediaTypes)

    JsonMediaTypeFormatter XmlMediaTypeFormatter ( application/xml  text/xml) FormUrlEncodedMediaTypeFor ...

  8. 为什么每个浏览器都有Mozilla字样?

    你是否好奇标识浏览器身份的)”,于是IE可以收到含有框架的页面了,所有微软的人都嗨皮了,但是网站管理员开始晕了. 因为微软将IE和Windows捆绑销售,并且把IE做得比Netscape更好,于是第一 ...

  9. 关于ol有序裂变和ul无序列表前面的列表项标记的位置

    使用列表项标记的时候发现其对齐方式竟然从内容开始,于是发现了这个属性可以解决: list-style-position inside 列表项目标记放置在文本以内,且环绕文本根据标记对齐. outsid ...

  10. SharePoint 2010 文档管理之文档推送

    前言:文档推送功能,不是一个复杂的功能,我们这里简单的应用了Ribbon定制.Js使用.对象模型推送(Server端),下面,我们来简单介绍下文档推送功能吧. 一. 功能设计: 文档推送功能,主要就是 ...