poj 2586

题意:每个月或者亏损s或者盈利d   调查8次连续的5个月  问若能盈利  则最大能盈利多少

贪心算法  :先求出能使五个月亏损的最小亏亏损月数  把那些亏损月数向后靠边

?





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

#include<iostream>

using
namespace std;

int main()

{

    int
s,d,i;

    while(cin>>s>>d)

    {

        for(i=1;i<=5;i++)

            if(d*i>(5-i)*s)

                break;

        if(i>=5)

        {

            cout<<"Deficit"<<endl;

            continue;

        }

        switch
(i)

        {

        case
1:if(d*2<s*10)

                cout<<s*10-d*2<<endl;

            else
cout<<"Deficit"<<endl;break;

        case
2:if(d*4<s*8)

                cout<<s*8-d*4<<endl;

            else
cout<<"Deficit"<<endl;break;

        case
3:if(d*6<s*6)

                cout<<s*6-d*6<<endl;

            else
cout<<"Deficit"<<endl;break;

        case
4:if(d*9<s*3)

                cout<<s*3-d*9<<endl;

            else
cout<<"Deficit"<<endl;break;

        }

    }

    return
0;

}

poj 2586,布布扣,bubuko.com

时间: 2024-08-19 04:15:18

poj 2586的相关文章

poj 2586 Y2K Accounting Bug (贪心)

Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9632   Accepted: 4806 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc.

POJ 2586:Y2K Accounting Bug(贪心)

Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10024 Accepted: 4990 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc. Al

[POJ 2586] Y2K Accounting Bug (贪心)

题目链接:http://poj.org/problem?id=2586 题目大意:(真难读懂啊)给你两个数,s,d,意思是MS公司每个月可能赚钱,也可能赔钱,如果赚钱的话,就是赚s元,如果赔钱的话,就是陪d元.现在告诉你只要是连续的5个月,就亏钱(亏多少不知道),问你MS公司全年能够赚多少钱,如果赚不了钱的话,就输出“Deficit” 贪心:我们说,输出的最终结果是f(x,y)=x*s-y*d,也就是说现在要求得x,y使得f(x,y)具有最大值. 当s,d,x+y给定时,x越大,则赚的钱越多.

Poj 2586 / OpenJudge 2586 Y2K Accounting Bug

1.Link: http://poj.org/problem?id=2586 2.Content: Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10520   Accepted: 5257 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some

POJ 2586 Y2K Accounting Bug(枚举大水题)

Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10674   Accepted: 5344 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc

poj 2586 Y2K Accounting Bug

Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10150   Accepted: 5061 题目大意:有家公司每个月有盈余s 和亏损d但不知道具体是那个月 只知道一年中每个连续的五个月都是亏损的.要求求出该公司这一年里最大的盈利的可能金额 若不能盈利就输出Deficit 注意如果s>4d也是要输出Deficit的 可以用分类方法去做 注意要保证每连续的五个月中都有n个d保证这五个月是

POJ 2586 贪心+枚举

Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15626   Accepted: 7843 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc

poj 2586 Y2K Accounting Bug【贪心】【刷题计划】

Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16154   Accepted: 8111 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc

POJ题目分类推荐 (很好很有层次感)

著名题单,最初来源不详.直接来源:http://blog.csdn.net/a1dark/article/details/11714009 OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 3094) 初期: 一.基本算法: 枚举. (POJ 1753,POJ 2965) 贪心(POJ 1328,POJ 2109,POJ 2586) 递归和分治法. 递