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

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

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

  1.   void Greedy(a[],n) {
  2. //A(1:n)包含n个输入
  3. solution = Φ //将解向量solution初始化为空
  4. for(j=;j=n;++j) {
  5. x = Select(a[]);
  6. if Feasible(solutionx) {solution=union(solutionx);}
  7. };//for
  8. return solution
  9. }// 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. (原创)win7自带IIS7.5+php7.0.10安装教程(图)

    php在上周8月18日发布了PHP 7.0 (7.0.10)版本.详细下载页面http://windows.php.net/download/,根据自身电脑配置情况酌情下载版本.win7旗舰版,iis ...

  2. Python PIL创建文字图片

    PIL库中包含了很多模块,恰当地利用这些模块可以做许多图像处理方面的工作. 下面是我用来生成字母或字符串测试图片而写的类及测试代码. 主要用到的模块: PIL.Image,PIL.ImageDraw, ...

  3. leetcode—sum root to leaf number

    题目如下: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a ...

  4. HW6.20

    public class Solution { public static void main(String[] args) { int[][] chessboard = new int[8][8]; ...

  5. HDU-4631 Sad Love Story 平面最近点对

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4631 数据是随机的,没有极端数据,所以可以分段考虑,最小值是一个单调不增的函数,然后每次分治算平面最近 ...

  6. Bugs及解决方案列表

    Bugs及解决方案列表(以下实例默认运行环境都为Standard mode): 如何在IE6及更早浏览器中定义小高度的容器? 方法: #test{overflow:hidden;height:1px; ...

  7. 把pgboucer做成postgresql服务

    把pgbouncer启动命令加入到postgresql服务配置里面.这样方便操作 vi /etc/init.d/postgresql 加入如下红色命令.路径换成你的pgbouncer安装目录 in s ...

  8. 教你50招提升ASP.NET性能(十一):避免在调试模式下运行网站

    (17)Avoid running sites in debug mode 招数17: 避免在调试模式下运行网站 When it comes to ASP.NET, one of the most c ...

  9. mysql select 报错

    代码片段: sql_url = "select * from webpage where url = '%s'" % b try: cursor.execute(sql_url) ...

  10. android 基于百度地图api开发定位以及获取详细地址

    一:百度地图开发必须要到百度开发平台android开发api下载相应的库,已经申请百度地图开发key. 二:新建项目baidumaplocation.设计main.xml文件这里注意的是MapView ...