在现实世界中,有这样一类问题:它有n个输入,而它的解就由这n个输入的某个子集组成,不过这个子集必须满足某些事先给定的条件。把那些必须满足的条件称为约束条件;而把满足约束条件的子集称为该问题的可行解。
问题的简单描述:
In={n个输入};             显然,满足约束条件的子
Ina是In的子集;             集可能不止一个,一般来说
Ina满足约定的条件;           可行解不是唯一的。
Ina构成问题的解。

  贪心方法是一种改进了的分级处理方法,选择能产生问题最优解的最优量度标准是使用贪心法设计求解的核心问题。但是,要选出最优量度标准并不是一件容易的事,不过,一旦能选择出某个问题的最优量度标准,那么用贪心方法求解这个问题则特别有效。

  贪心方法可以用下面的抽象化控制来描述:

  void Greedy(a[],n) {
//A(1:n)包含n个输入
solution = Φ //将解向量solution初始化为空
for(j=;j=n;++j) {
x = Select(a[]);
if Feasible(solution,x) {solution=union(solution,x);}
};//for
return solution;
}// Greedy

  函数Select的功能是按某种最优量度标准从A(1:n)中选择一个输入,把它的值赋给x并从输入集合A中消去它。Feasible是一个布尔函数,它判定x是否可以包含在解向量中。union将x与解向量结合并修改目标函数。过程Greedy描述了用贪心策略设计算法的主要工作和基本控制路线。一旦给出一个特定的问题,就可将Select,Feasible和 Union具体化并付诸实现。

Greedy的更多相关文章

  1. USACO . Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...

  2. hdu4976 A simple greedy problem. (贪心+DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=4976 2014 Multi-University Training Contest 10 1006 A simp ...

  3. ACM Greedy Mouse

    Greedy Mouse 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 A fat mouse prepared M pounds of cat food,read ...

  4. hdu 1053 (huffman coding, greedy algorithm, std::partition, std::priority_queue ) 分类: hdoj 2015-06-18 19:11 22人阅读 评论(0) 收藏

    huffman coding, greedy algorithm. std::priority_queue, std::partition, when i use the three commente ...

  5. Greedy is Good

    作者:supernova 出处:http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=greedyAlg Joh ...

  6. 九度OJ 1453 Greedy Tino -- 动态规划

    题目地址:http://ac.jobdu.com/problem.php?pid=1453 题目描述: Tino wrote a long long story. BUT! in Chinese... ...

  7. 119 - Greedy Gift Givers

     Greedy Gift Givers  The Problem This problem involves determining, for a group of gift-giving frien ...

  8. ZOJ 3794 Greedy Driver

    两次SPFA 第一关找:从1没有出发点到另一个点的多少是留给油箱 把边反过来再找一遍:重每一个点到终点最少须要多少油 Greedy Driver Time Limit: 2 Seconds       ...

  9. Greedy Change

    Greedy Change time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

随机推荐

  1. bzoj 3197 [Sdoi2013]assassin(Hash+DP+KM)

    Description Input Output Sample Input 4 1 2 2 3 3 4 0 0 1 1 1 0 0 0 Sample Output 1 HINT [思路] Hash,D ...

  2. uvalive 2797 Monster Trap

    题意:给定一些线段障碍,判断怪物能不能逃离到无穷远处. 思路:从(0,0)点能否到无穷远处.用BFS搜索.那满足什么样的点符合要求,能加入到图中呢? 遍历每个点,显然一开始已经在某些线段上的点要删去. ...

  3. Redhat Enterprise Linux 6.4图形界面的中文问题

    一.界面中文,但Windows中的中文文件名上传到linux后乱码. .bashrc文件: export LANG=zh_CN.UTF-8 /etc/sysconfig/i18n文件: LANG=&q ...

  4. leetcode@ [173] Binary Search Tree Iterator (InOrder traversal)

    https://leetcode.com/problems/binary-search-tree-iterator/ Implement an iterator over a binary searc ...

  5. jqgrid在页面出来竖型滚动条自动调整列宽

    在项目中使用jqgrid的时候,需要设置在页面竖型滚动条出来的时候,列宽进行调整 1. 判断jqgrid的宽度是否和页面的宽度不一致(判断滚动条是否出来) 2. 调整jqgrid的列宽,因为jqgri ...

  6. Failed to install apk on device timeout

    安装应用时遇到下面的错误   Failed to install *.apk on device timeout 在eclipse中,window->prefreences->DDMS-& ...

  7. hdu 1034 Candy Sharing Game

    Candy Sharing Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  8. [iOS基础控件 - 3.4] 汤姆猫

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...

  9. 上传GIF图片方法!

    有朋友问,如何上传GIF图片,在此做一下说明.方法是:在第二栏“上传图片”栏——选择“无水印”——选择文件(找到文件)——点击上传——点击插入——我选的图片 ——上传成功了!

  10. window 便笺

    windows的便签很方便人们记录日常工作安排,但是不是所有人都知道如何调用,下面介绍下如何调用windows便签: 1.win + R -->  StikyNot 2.弹出便签界面 3.右击底 ...