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 ...
随机推荐
- 多个jsp页面共享Java bean
通过jsp的内置对象—request对象获取参数: 通过超链接传参: 例:把a.jsp中i的值传到b.jsp中: 在a.jsp页面中的核心代码为: <a href="b.jsp?i=1 ...
- knn手写识别
import numpy as np import operator import os #KNN算法 def knn(k,testdata,traindata,labels):#(k,测试样本,训练 ...
- Fb 第三方接口
1.Facebook ID? User ID / https://www.piliapp.com/facebook/id/?url=https%3A%2F%2Fwww.facebook.com%2Fz ...
- 如何获取某个网站的favicon.ico
http://moco.imooc.com/player/report.html 今天看到这个网站上,左侧的小图片挺好看的,想弄下来,检查源码,也没有看到 <head> <meta ...
- mydqldump
[mydqldump] One way to create a snapshot of the data in an existing master database is to use the my ...
- SpringMVC源码总结(一)HandlerMapping和HandlerAdapter入门
SpringMVC在使用过程中,大多是使用注解,对它的实现接口之类的关系理解变得模糊, 通过对XML配置的理解,可以理清各个类的关系,譬如控制器类要实现Controller接口. 接触SpringMV ...
- python简单基础代码
1.从键盘输入两个数,并计算A的B次幂:number1=raw_input('input number1:')number2=raw_input('input number2:')print 'num ...
- subprocess 粘包问题
1.执行命令: 在py代码中去如何调用操作系统的命令 新模块:subprocess r = subprocess.Popen('ls',shell=True,stdout=subprocess.PIP ...
- 探讨 .NET 4 新增的 SortedSet 类
http://www.cnblogs.com/WizardWu/archive/2010/06/17/1759297.html
- ROS两种workspace :overlay rosbuild_ws->catkin_ws->ROS库,
概念 ROS里面有一系列概念,作为初学者,最先接触的概念无非是node, package和workspace. node node是ROS里面最小的执行单位,你可以把node看成是一个main函数,当 ...