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. P6 Enterprise Project Portfolio Contract Management

    Find documentation for Primavera products here: Primavera Cloud Services Primavera Prime Primavera P ...

  2. JS浏览器全屏

    //全屏 function fullScreen() { var el = document.documentElement; var rfs = el.requestFullScreen || el ...

  3. html5人物图片360度立体旋转

    体验效果:http://hovertree.com/texiao/html5/10.htm 下载:http://hovertree.com/hvtart/bjae/t16oddyt.htm 代码如下: ...

  4. ActiveReports 报表应用教程 (5)---解密电子商务领域首张电子发票的诞生(套打报表)

    6月27日京东商城发布了中国电子商务领域首张电子发票,同时宣布相关系统正式上线,这标志着中国电子商务的步伐又向前迈出了重要的一步.目前“电子发票”覆盖的服务范围是在北京地区购买图书.音像商品的个人消费 ...

  5. 用于dbnull的数据转换。因为用convert.to无法转换dbnull类型

    /// <summary> /// add by wolf /// </summary> public static class ExtendObject { public s ...

  6. js注入,黑客之路必备!

    最近刚出了新闻,阿里四名网络安全部门员工利用网页漏洞写js脚本抢月饼,于是兴致来了,想了解一下这个js脚本到底怎么写,各种刷单各种抢枪抢又是怎么实现的. 什么是javascript注入攻击? 1.每当 ...

  7. php学习笔记:文件的上传(包含设置文件的上传大小限制)

    今天写的是文件上传,前几天自学的正规则又忘记了,用了很笨的方法去判断格式,直接上代码: <?php /** * Created by PhpStorm. * User: Administrato ...

  8. 挖掘机技术哪家强(c++实现)

    描述:为了用事实说明挖掘机技术到底哪家强,组织一场挖掘机技能大赛.现请你根据比赛结果统计出技术最强的那个学校. 输入:输入在第1行给出不超过105的正整数N,即参赛人数.随后N行,每行给出一位参赛者的 ...

  9. 盒模型结构——3D盒模型

  10. SAP中关于用户IP信息的获取(转载)

    SAP中如何获取登录用户的IP? 或如何查看哪些IP登录到SAP中: 在Table: USR41中查看,具体字段的说明如下: MANDT   ---   ClientBNAME   ---   登录的 ...