Git Product home page Git Product logo

greedy-algorithm's Introduction

Greedy-algorithm

贪心算法 适用于最优子结构 即一个问题的最优解可以由它的子问题的最优解有效的构造出来。

简单贪心

1.mooncake :这里采用“总是选择单价最高的月饼出售,可以获得最大的利润的策略” 2. 将所有月饼按单价从高到低排序。


输入样例:  

3 20

18 15 10

75 72 45

输出:  

94.5


月饼库存量,总售价,总需求量D 可以是浮点型,用double存储。


当月饼库存量高于需求量时,循环中断(break)

2.min numbers :从1-9中选择个数不为0的最小的数输出,然后从0-9输出数字,每个数字输出次数为其剩余个数。

区间贪心

区间不想交问题:给出N个开区间,从中选择进可能多的开区间,使得它们两两没有交集。

greedy-algorithm's People

Contributors

huwenyue avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.