HDU3664 Permutation Counting
Permutation Counting
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1487 Accepted Submission(s): 754
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}
- /*
- ID: LinKArftc
- PROG: 3664.cpp
- LANG: C++
- */
- #include <map>
- #include <set>
- #include <cmath>
- #include <stack>
- #include <queue>
- #include <vector>
- #include <cstdio>
- #include <string>
- #include <utility>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- #define eps 1e-8
- #define randin srand((unsigned int)time(NULL))
- #define input freopen("input.txt","r",stdin)
- #define debug(s) cout << "s = " << s << endl;
- #define outstars cout << "*************" << endl;
- const double PI = acos(-1.0);
- const double e = exp(1.0);
- const int inf = 0x3f3f3f3f;
- const int INF = 0x7fffffff;
- typedef long long ll;
- const int maxn = ;
- const int MOD = ;
- ll dp[maxn][maxn];
- int n, k;
- void init() {
- dp[][] = ;
- dp[][] = ;
- for (int i = ; i <= ; i ++) {
- for (int j = ; j <= ; j ++) {
- dp[i+][j] = (dp[i+][j] % MOD + (j + ) * dp[i][j] % MOD) % MOD;
- dp[i+][j+] = (dp[i+][j+] % MOD + (i - j) * dp[i][j] % MOD) % MOD;
- }
- }
- }
- int main() {
- init();
- while (~scanf("%d %d", &n, &k)) {
- printf("%d\n", dp[n][k]);
- }
- return ;
- }
HDU3664 Permutation Counting的更多相关文章
- hdu3664 Permutation Counting(dp)
hdu3664 Permutation Counting 题目传送门 题意: 在一个序列中,如果有k个数满足a[i]>i:那么这个序列的E值为k,问你 在n的全排列中,有多少个排列是恰好是E值为 ...
- hdu 3664 Permutation Counting(水DP)
Permutation Counting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 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
Discription Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the amount of ...
- HDU 3664 Permutation Counting (DP)
题意:给一个 n,求在 n 的所有排列中,恰好有 k 个数a[i] > i 的个数. 析:很明显是DP,搞了好久才搞出来,觉得自己DP,实在是太low了,思路是这样的. dp[i][j]表示 i ...
- HDU 6880 Permutation Counting dp
题意: 给你一个n和一个长度为n-1的由0/1构成的b序列 你需要从[1,n]中构造出来一个满足b序列的序列 我们设使用[1,n]构成的序列为a,那么如果ai>ai+1,那么bi=1,否则bi= ...
- UVALive 5971
Problem J Permutation Counting Dexter considers a permutation of first N natural numbers good if it ...
- LeetCode_Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permuta ...
- CH3602 Counting Swaps
题意 3602 Counting Swaps 0x30「数学知识」例题 背景 https://ipsc.ksp.sk/2016/real/problems/c.html Just like yeste ...
随机推荐
- 九度OJ--Q1473
import java.util.ArrayList;import java.util.Scanner; /* * 题目描述: * 大家都知道,数据在计算机里中存储是以二进制的形式存储的. * 有一天 ...
- Python 3 学习笔记之——数据类型
1. 数字 类型 int, float, bool, complex type() 查看变量类型 isinstance(a, int) 查看变量类型 运算符 % 取余 // 返回商的整数部分 ** 幂 ...
- Pro Git - 笔记2
Git Basics Getting a Git Repository Initializing a Repository in an Existing Directory For Linux: $ ...
- lintcode-91-最小调整代价
91-最小调整代价 给一个整数数组,调整每个数的大小,使得相邻的两个数的差不大于一个给定的整数target,调整每个数的代价为调整前后的差的绝对值,求调整代价之和最小是多少. 注意事项 你可以假设数组 ...
- JDK源码分析 – Integer
Integer类的申明 public final class Integer extends Number implements Comparable<Integer> { … } Int ...
- java第七笔记
- 在Linux下调试Python代码的各种方法
这是一个我用于调试或分析工具概述,不一定是完整全面,如果你知道更好的工具,请在评论处标记. 日志 是的,的确,不得不强调足够的日志记录对应用程序是多么的重要.您应该记录重要的东西,如果你的记录足够好的 ...
- Python执行Linux系统命令的4种方法
http://www.jb51.net/article/56490.htm (1) os.system 仅仅在一个子终端运行系统命令,而不能获取命令执行后的返回信息 复制代码代码如下: system( ...
- 【Python】Python学习----第一模块笔记
1.python是什么? python是动态解释型的强类型定义语言. python官方版本的解释器是CPython.该解释器使用C语言开发. 当前主要使用3.x版本的python. 2.第一个pyth ...
- 【bzoj2815】[ZJOI2012]灾难 拓扑排序+倍增LCA
题目描述(转自洛谷) 阿米巴是小强的好朋友. 阿米巴和小强在草原上捉蚂蚱.小强突然想,果蚂蚱被他们捉灭绝了,那么吃蚂蚱的小鸟就会饿死,而捕食小鸟的猛禽也会跟着灭绝,从而引发一系列的生态灾难. 学过生物 ...