HDU-3664-Permutation Counting
Permutation Counting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the amount of elements where ai > i. For example, the E-value of permutation {1, 3, 2, 4} is 1, while the E-value of {4, 3, 2, 1} is 2. You are requested to find how many permutations of {1, 2, …, N} whose E-value is exactly k. Input There are several test cases, and one line for each case, which contains two integers, N and k. (1 <= N <= 1000, 0 <= k <= N). Output Output one line for each case. For the answer may be quite huge, you need to output the answer module 1,000,000,007. Sample Input 3 0 3 1 Sample Output 1 4 Hint 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} Source 2010 Asia Regional Harbin Recommend |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
ll d[1010][1010];
int main()
{d[1][0]=1;for(int i=1;i<=1000;i++)d[1][i]=0;for(int i=2;i<=1000;i++){for(int j=0;j<=i;j++){d[i][j]=d[i-1][j]+d[i-1][j]*j+d[i-1][j-1]*(i-j); d[i][j]%=MOD;} } int n,k;while(cin>>n>>k){cout<<d[n][k]<<endl;}return 0;
}
HDU-3664-Permutation Counting相关推荐
- HDU 3664 Permutation Counting
Permutation Counting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- HDU 3664 Permutation Counting(DP)
题目链接 弱爆啦,组合弱爆了,反正是没想出来怎么搞这个题,其实这个公式不难推啊,反正就是没推出来.今天队内赛,实在是没办法了,暴力写了个DFS,先把10以内的打出表来,发现类似杨辉三角的一个表,推不出 ...
- HDU多校10 - 6880 Permutation Counting(dp+思维)
题目链接:点击查看 题目大意:给出一个长度为 n - 1 的 01 序列 b 用来表示排列 a 的相对大小关系,b[ i ] = 0 说明 a[ i ] < a[ i + 1 ] ,b[ i ] ...
- hdu 3664 1~n排列(aii ) 为k个数
http://acm.hdu.edu.cn/showproblem.php?pid=3664 求1~n的排列个数,使得逆序数(ai>i ) 为给定的k. dp[i][j]表示前1~i的排列中,有 ...
- 后缀数组 --- HDU 3518 Boring counting
Boring counting Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=3518 Mean: 给你一个字符串,求:至少出 ...
- HDU 4917 Permutation(拓扑排序 + 状压DP + 组合数)
题目链接 Permutation 题目大意:给出n,和m个关系,每个关系为ai必须排在bi的前面,求符合要求的n的全排列的个数. 数据规模为n <= 40,m <= 20. 直接状压DP空 ...
- 【DP】【Asia - Harbin - 2010/2011】【Permutation Counting】
[题目描述]Given a permutation a1, a2,...aN of {1, 2,..., N}, we define its E-value as the amount of elem ...
- 【HDU - 6184】Counting Stars(三元环计数,二分,优化暴力,O(m*sqrt(m)),图论)
题干: Little A is an astronomy lover, and he has found that the sky was so beautiful! So he is countin ...
- hdu 4345 Permutation
http://acm.hdu.edu.cn/showproblem.php?pid=4345 记忆化搜索 dp 比赛的时候没想出来呀亲 此题和 置换群有那么丁点关系 但关系不大 题目让我们求的是 实 ...
- HDU 1718 Rank counting sort解法
本题是利用counting sort的思想去解题. 注意本题,好像利用直接排序,然后查找rank是会直接被判WA的.奇怪的推断系统. 由于分数值的范围是0到100,很小,而student 号码又很大, ...
最新文章
- pytorch使用empty跟内建函数random_进行初始化Tensor
- windows10 安装docker
- sublime c 语言 编译环境搭建,详解sublime搭建C/C++编译环境
- 东芝硬盘插入台式机后滴滴响
- 使用jps来查看虚拟机状态
- 每次点击添加css动画,div点击添加css动画
- Spring-beans-BeanPostProcessor/InitializingBean
- 我的博客园开张了,记录每天学习,工作。
- 文本处理三剑客之gawk
- c语言文件打开幕式,c语言奥运会开幕式
- 阮一峰ES6学习笔记
- 使用adb shell screencap命令截图
- LoadRunner视频教程
- BOOTCAMP U盘安装WIN7一直显示无法创建可引导的USB驱动器
- 算法题目打卡:Ques20201019
- C,D,Go,Rust,Nim,Zig,V,Julia,Py,C#,Kotlin 11语回文数大战!仅供娱乐参考!
- C printf() 详解之终极无惑
- iPhone12充电功率多少W
- 怎样把多个TXT文件合成为一个TXT文件
- 公众号被处罚后排名下滑
热门文章
- Qt之Concurrent框架
- SQL-Server使用点滴(一-数据对象篇)
- 【BZOJ-3033】太鼓达人 欧拉图 + 暴搜
- C# MVC使用阿里云对象存储加快图片加载速度(一)
- Visual.Assist.X.V10.7.1940的汉化破解补丁
- CentOS离线安装gcc环境(附安装包+图文并茂)
- Linux|CentOS下配置Maven环境
- android webView注入js方法
- php5.3 sql server,php5.3连接sqlserver2005
- Springcloud整理