一道经典Dp不过现在还不是能特别理解。定义dp[i][j] 表示由i个节点,j 层高度的累计方法数状态转移方程为: 用i个点组成深度最多为j的二叉树的方法树等于组成左子树的方法数乘于组成右子树的方法数再累计。暂贴代码:/*ID: wushuai2PROG: nocowsLANG: C++*///#p...
分类:
其他好文 时间:
2015-02-21 15:25:57
阅读次数:
170
又一水,设dp[i]为以i结尾的有最大平均值的起始位置。#include #include #include #include #include #include #include #include #include using namespace std;int cow[100010];int d...
分类:
其他好文 时间:
2015-02-20 09:38:57
阅读次数:
300
题目链接:http://i.cnblogs.com/EditPosts.aspx?opt=1Catch That CowTime Limit: 5000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submi...
分类:
其他好文 时间:
2015-02-18 18:47:58
阅读次数:
153
二分图的最大匹配。我是用最大流求解。加个源点s和汇点t;s和每只cow、每个stall和t 连一条容量为1有向边,每只cow和stall(that the cow is willing to produce milk in )也连一条容量为1的边。然后就用ISAP。#include#include#...
分类:
其他好文 时间:
2015-02-18 15:13:26
阅读次数:
184
Feed Ratios1998 ACM Finals, Dan Adkins Farmer John feeds his cows only the finest mixture of cow food,which has three components: Barley, Oats, and Wheat. While he knowsthe precise mixture of these...
分类:
移动开发 时间:
2015-02-17 21:06:33
阅读次数:
237
字符串动态规划 匹配时两指针的重要思想 针对原串从后往前 不需要string类
分类:
其他好文 时间:
2015-02-15 19:23:05
阅读次数:
154
题目链接:http://poj.org/problem?id=3176#include #include #include #include #include #include #include #include #include #include #include using namespace ...
分类:
其他好文 时间:
2015-02-15 13:22:44
阅读次数:
168
#include <iostream>
#include <string>
using namespace std;
typedef struct BiTNode
{
int data;
int flag;
BiTNode *lchild,*rchild;
} BTNode,BTree;
//二叉排序树的查找非递归算法
//在二叉...
分类:
其他好文 时间:
2015-02-13 16:47:02
阅读次数:
129
这道题整整思考了两天,最终还是AC啦!初看觉得这道题有三个维度,分别是智商和要大于0,幽默感的和要大于0,同时,智商和幽默感的和又要最大。而事实上,只要求出每个可能的智商值对应的最大的幽默感值即可。由于智商和幽默感都存在负数,所以智商和的值要整体向右平移100*1000个单位。而S[i]则表示,智商在i(实际上和为i-100*1000)对应的最大幽默感和,且初始时S[i]的值都为负无穷。接下来就可...
分类:
其他好文 时间:
2015-02-12 14:01:05
阅读次数:
190
题意:给出一个电梯,给出它的层数f,给出起点s,终点g,以及在每一层能够上或者下w[i]层,问至少需要按多少次按钮到达终点。和POJ catch that cow一样,直接用了那一题的代码,发现一直wa,后来才发现,POJ catch that cow是单组输入的,所以每次调用的时候不用清空队列,而...
分类:
其他好文 时间:
2015-02-12 10:39:13
阅读次数:
164