![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 61
Ping_QC
这个作者很懒,什么都没留下…
展开
-
HDOJ-1176-免费馅饼-动态规划
<br />这个问题可以保存到一个二维数组里面,如图<br />横坐标x0~10(由题意知道),中坐标T (0~100000), 这样就可以int a[100005][11];<br /><br />再从倒数第二层开始从右往左,从下到上遍历<br /><br />如上图。将下面三个中值最大的赋值给a[i][j]<br />最后,因为开始在5点。所以答案一定是a[1][4],a[1][5], a[1][6]中最大的那个<br /> <br />#include <cstdio> #include <cstr原创 2011-04-13 14:08:00 · 1127 阅读 · 0 评论 -
HDOJ-Crixalis's Equipment
不知道这算贪心还是DP,反正是AC了思路:根据ai 和 bi 的差降序排一下。差相同的根据ai升序排序然后看能否从头到尾走一遍好像vc6里面node有特殊意思,开始写node[1005]结果结构体里面的a,b,c都是0#include #include using namespace std; struct Node{ int a, b, c; } nd[1005]; bool cmp( Node x, Node y){ if( x. c !=原创 2011-04-11 12:35:00 · 1378 阅读 · 1 评论 -
HDOJ-2501-Tiling_easy version
<br />这题很水,但还是写一下。主要是写下怎么找规律<br />找规律的话,如果有耐心,可以拿只笔一个个的画下(但我不保证不会失误),<br />另外就是写程序模拟一下。这题用的是dfs<br />每次添加有3中情况<br />a) 添加一块2x1的<br />b) 添加一块2x2的<br />c) 添加两块2x1的,横放,与3块2x1的区别开<br />然后搜索,每得到一次结果记录一下。<br />下面是代码<br />这里找了前20组,本来想全部找出来的,课程序吃不消<br />#include <原创 2011-04-12 18:23:00 · 1017 阅读 · 0 评论 -
HDOJ-考试排名
没什么难度,只要能处理一些字符串就行了格式很蛋疼啊PE了两次#include #include #include #include using namespace std; struct Node{ char name[20]; int cnt, time; }a[50000]; bool cmp(Node p, Node q){ if(p.cnt != q.cnt) return p.cnt > q.cnt; if(p.time != q.time) re原创 2011-04-11 13:01:00 · 959 阅读 · 0 评论 -
HDOJ-Monkey and Banana-动态规划
#include #include using namespace std; struct Node{ int x, y, z; }aa[100]; int a, b, c; int main(){ int t = 1, i, idx, n, ans, j, tmp; void exchange(); bool cmp(Node p, Node q); while(scanf("%d",&n),n){ ans = -1; for(i = idx = 0; i原创 2011-04-14 15:13:00 · 977 阅读 · 0 评论 -
java 版字典树
public class Main { public static void main(String[] args) { String[] str = { "asdf", "asji", "bjkl", "cdsdf", "jdsfk" }; Trie root = new Trie(); for (String s : str) { insert(root, s); }原创 2012-04-08 14:29:04 · 2546 阅读 · 0 评论 -
HDU 1009 FatMouse' Trade
为了更深层次的了解java,继续上OJ A题 import java.io.BufferedInputStream; import java.util.Arrays; import java.util.Scanner; public class Main { private static Scanner cin = new Scanner(new BufferedInputStream(Sy原创 2012-04-16 15:55:23 · 1367 阅读 · 0 评论