推荐网址,下面是别人的解题报告: http://www.cnblogs.com/chasetheexcellence/archive/2012/04/16/poj2441.html 里面有状态压缩论文的链接,可以看看. 该解题报告中用的是二维数组,但是很显然的是,递推式中的下一行只与上一行有关,类似于最长公共子序列,可以用滚动数组,在滚动数组后发现只用一个数组就可以了.至于是不是要和0-1背包一样得按从大到小的顺序,我没有,我的状态是从小到大的顺序,但是也AC了. 如果不用滚动数组,会超内存.…
题目链接: http://poj.org/problem?id=2441 Arrange the Bulls Time Limit: 4000MSMemory Limit: 65536K 问题描述 Farmer Johnson's Bulls love playing basketball very much. But none of them would like to play basketball with the other bulls because they believe that…
Description Farmer Johnson's Bulls love playing basketball very much. But none of them would like to play basketball with the other bulls because they believe that the others are all very weak. Farmer Johnson has N cows (we number the cows from 1 to…
[题目链接] 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]…
Arrange the Bulls Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 5427   Accepted: 2069 Description Farmer Johnson's Bulls love playing basketball very much. But none of them would like to play basketball with the other bulls because the…
题意很简单,n头牛,m个位置,每头牛有各自喜欢的位置,问安排这n头牛使得每头牛都在各自喜欢的位置有几种安排方法. 2000MS代码: #include <cstdio> #include <cstring> <<)+]; << ) + ]; //用来数出状态为i时1的个数,具体到这个题中就是 //状态为i时有多少头牛已经安排好牛棚 void CountOne(int m) { ; i< ( << m); ++i) { ; ; j< m…
不容易系列之一 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13566    Accepted Submission(s): 5660 Problem Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的…
I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个数为x和y),而且要求x<=y. 通过找规律可以发现,这个题就是求解a*x+b*y=k这个方程的x和y的值,并且要x和y为最小满足条件的解.可以找规律出一个公式fi[i]*x+(fi[i-1]+fi[i])*y=n.因为不知道n具体是在第几步推出来的,所以for循环跑一遍预处理出来的斐波那契数列(存…
Problem 1147 Tiling Time Limit: 1000 mSec Memory Limit : 32768 KB http://acm.fzu.edu.cn/problem.php?pid=1147  Problem Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tiling of a 2x17 rectangle.  Input I…
原题链接 参考代码: #include <iostream> using namespace std; typedef long long ll; + ; ll dp[maxn]; int main() { ll t, a, b, now; dp[] = ; dp[] = ; ; i <= maxn; i ++) { dp[i] = dp[i - ] + dp[i - ]; } cin >> t; while(t --) { cin >> a >> b…