ignatius专题

HDU Ignatius and the Princess IV

题目传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1029 看来写这类题目必须要创新的思路,纯粹的写循环很容易被大数据爆掉。下面是一份超时代码,目前还没有发现原因,没有死循环,目测是数据量大的原因? #include<stdio.h>#include<string.h>#include<algorithm>//#define LOCAL

杭电OJ 1027:Ignatius and the Princess II

题目的大意就是求一串数字的全排列的第m小的排列,比如1,2,3是3个数的最小的全排列,1,3,2是次小的全排列。这个题目可以用STL的一个函数next_permutation,这个函数是用来生成一个全排列的下一个全排列,当然也可以自己写生成排列算法,生成一个全排列的下一个全排列的算法如下: (1)从数组最后一个开始往前找,假设后一个记为p,前一个记为pre,直到找到一个满足A[pre]<A[p]

Ignatius and the Princess II【HDOJ1027】

题目链接 #include<cstdio>#include<algorithm>using namespace std;int main(){int n,m;int arr[1010];while(scanf("%d%d",&n,&m)!=EOF){for(int i=1;i<=n;i++){arr[i]=i;}int cnt=0;do{cnt++;if(cnt==m){for(int i

ACM DP Ignatius and the Princess IV

题目: "OK, you are not too bad, em... But you can never pass the next test." feng5166 says.  "I will tell you an odd number N, and then N integers. There will be a special integer among them, you ha

HDU——1028 Ignatius and the Princess III(母函数)

Problem Description “Well, it seems the first problem is too easy. I will let you know how foolish you are later.” feng5166 says. “The second problem is, given an positive integer N, we define an eq

HDU 1027:Ignatius and the Princess II ← next_permutation()

【题目来源】http://acm.hdu.edu.cn/showproblem.php?pid=1027【题目描述】 Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the

HDU1028 Ignatius and the Princess III(整数拆分:母函数||DP)

题意: 给出一个值n,问有几种不同的拆分方法。 要点: 可以用母函数或DP来做,这里说一下母函数,基本思路是:写成(1+x^2+x^3+x^4……x^n)*(1+x^2+x^4+……)*(1+x^3+x^6+……)……这样,然后利用循环从每个括号开始算起,用c1存储前一次算出的所有指数对应的系数,c2暂存算上当前括号的对应系数,最后c1[n]就是答案。 母函数: 18281776201

[kuangbin带你飞]专题十二 基础DP1 -B - Ignatius and the Princess IV

“OK, you are not too bad, em… But you can never pass the next test.” feng5166 says. “I will tell you an odd number N, and then N integers. There will be a special integer among them, you have to tel