Arrange the Bulls [POJ2441] [状压DP]】的更多相关文章

题意 n头牛,m个房间,每头牛有自己喜欢的房间,问每头牛都住进自己喜欢的房间有多少种分配方法? Input In the first line of input contains two integers N and M (1 <= N <= 20, 1 <= M <= 20). Then come N lines. The i-th line first contains an integer P (1 <= P <= M) referring to the numb…
题目是,有n头牛,每头牛都喜爱某几个草地,要把这n头牛分配给m个不同的它们喜爱的草地,问有几种分配方式. dp[n][S]表示前n头牛分配完毕后占用的草地集合是S的方案数 dp[0][0]=1 dp[n][S]+=dp[n-1][S-x](x∈S且n喜爱x) 不过的状态这样空间开销太大了,事实上n这个维度的信息S就包含了,所以dp[S]即可. #include<cstdio> #include<cstring> #include<algorithm> using nam…
[题目链接] http://poj.org/problem?id=2441 [题目大意] 每个人有过个喜欢的篮球场地,但是一个场地只能给一个人, 问所有人都有自己喜欢的场地的方案数. [题解] 状态S表示已经用了那些场地,顺序递推每个人满足需求的情况即可. [代码] #include <cstdio> #include <cstring> using namespace std; const int N=25; int n,m,u,x,dp[2][1<<20],a[N]…
Doing Homework Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadline, the…
Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadline, the teacher will reduce his score of t…
http://acm.hdu.edu.cn/showproblem.php?pid=1074 Doing Homework Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12269    Accepted Submission(s): 5911 Problem Description Ignatius has just come bac…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 Time Limit: 2 Seconds      Memory Limit: 65536 KB The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order…
也就作业几题而已,分析一下提醒 最重要的就是,记住,没用的状态无论怎么转移最后都会是没用的状态,所以每次转移以后的有值的状态都是有用的状态. 几种思考方向: 第一种:枚举当前的状态,转移成另外一个状态 第二种:枚举最终状态,然后通过另外一个枚举能转移到这种状态 ①就是给你一个地图,然后这个图上面1的可以放东西,0的不能放,问一共有n个东西,每个东西只能放在特定的几个位置上,最多有几种?POJ2441 这个问题就是,因为地图之间的每个空间都是很大的,如果只是普通的dp是无法进行状态转移的,因此这道…
Doing Homework Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12174    Accepted Submission(s): 5868 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a l…
The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order of the problems. As we know, the arrangement will have a great effect on the result of the contest. For example, it will…