hdu 3664 Permutation Counting(水DP)
Permutation Counting
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1171 Accepted Submission(s): 587
3 1
4
There is only one permutation with E-value 0: {1,2,3}, and there are four permutations with E-value 1: {1,3,2}, {2,1,3}, {3,1,2}, {3,2,1}
题意:
#include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=100010;
const int mod=1000000007;
__int64 dp[1010][1010];
int main()
{
int i,j,n,k; for(i=1;i<=1000;i++)
{
dp[i][0]=1;
dp[i][i]=0;
for(j=1;j<i;j++)
dp[i][j]=((j+1)*dp[i-1][j]+(i-j)*dp[i-1][j-1])%mod;
}
while(~scanf("%d%d",&n,&k))
printf("%I64d\n",dp[n][k]);
return 0;
}
hdu 3664 Permutation Counting(水DP)的更多相关文章
- HDU - 3664 Permutation Counting 排列规律dp
Permutation Counting Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the ...
- HDU 3664 Permutation Counting (DP)
题意:给一个 n,求在 n 的所有排列中,恰好有 k 个数a[i] > i 的个数. 析:很明显是DP,搞了好久才搞出来,觉得自己DP,实在是太low了,思路是这样的. dp[i][j]表示 i ...
- HDU - 3664 Permutation Counting
Discription Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the amount of ...
- hdu3664 Permutation Counting(dp)
hdu3664 Permutation Counting 题目传送门 题意: 在一个序列中,如果有k个数满足a[i]>i:那么这个序列的E值为k,问你 在n的全排列中,有多少个排列是恰好是E值为 ...
- hdu 2571 命运(水DP)
题意: M*N的grid,每个格上有一个整数. 小明从左上角(1,1)打算走到右下角(M,N). 每次可以向下走一格,或向右走一格,或向右走到当前所在列的倍数的列的位置上.即:若当前位置是(i,j), ...
- HDU 6880 Permutation Counting dp
题意: 给你一个n和一个长度为n-1的由0/1构成的b序列 你需要从[1,n]中构造出来一个满足b序列的序列 我们设使用[1,n]构成的序列为a,那么如果ai>ai+1,那么bi=1,否则bi= ...
- HDU 3811 Permutation 状压dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3811 Permutation Time Limit: 6000/3000 MS (Java/Othe ...
- hdu 5753 Permutation Bo 水题
Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- hdu 1241 搬寝室 水dp
搬寝室 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Desc ...
随机推荐
- Dotfuscator Professional Edition获取代码发布和混淆代码
1 Dotfuscator Professional Edition 4.9 破解版 下载地址:http://www.pc0359.cn/downinfo/39815.html 备份地址:C:\D\9 ...
- WinForm多线程编程与Control.Invoke的应用浅谈
在WinForm开发中,我们通常不希望当窗体上点了某个按钮执行某个业务的时候,窗体就被卡死了,直到该业务执行完毕后才缓过来.一个最直接的方法便是使用多线程.多线程编程的方式在WinForm开发中必不可 ...
- github page更新后不生效
昨晚在本地git仓库修改了页面内容后,git push上去,到页面去刷新发现,并没有改变.本来还想着是需要点时间来更新,就再等等. 没想到过了十几分钟后,还是没有更新. 然后同时习惯性地打开了邮箱,发 ...
- js获取地址栏信息
参考: http://www.w3school.com.cn/jsref/dom_obj_location.asp http://www.xxx.com:8081/ location.host = w ...
- 【MySQL报错】ERROR 1558 (HY000): Column count of mysql.user is wrong. Expected 43, found 39.
原文参考:http://wuzhuti.cn/2348.html 之前在centos6.4系统安装的是自带的mysql 5.1版本,后来升级到了5.6版本,执行以下命令报错 在网上查找原因说说因为升级 ...
- MD5摘要算法实现
网上找到的实现md5函数代码,包括一个头文件md5.h和一个源文件md5.c,用下面的测试代码test.c测试通过,各文件依次如下: 头文件md5.h: #ifndef MD5_H #define M ...
- nyoj1076-方案数量 【排列组合 dp】
http://acm.nyist.net/JudgeOnline/problem.php?pid=1076 方案数量 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 ...
- [leetcode]158. Read N Characters Given Read4 II - Call multiple times 用Read4读取N个字符2 - 调用多次
The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actu ...
- DataTable学习笔记---排序细则、列隐藏
耽误了好几天,因为要做一个嵌入式的实验-android内核编译与裁剪,很久之前装的wubi不知道为什么运行出错了,然后看着当前的win7系统觉得有点讨厌了,也是因为快1年半没装机了,所以就重新装机了, ...
- dede 复制文章,远程图片无法本地化
解决方法: 1.找到dede的后台目录,在后台目录下的inc下找到inc_archives_functions.php 2.搜索GetCurContent函数,找到如下这段代码: preg_match ...