poj2586(Y2K Accounting Bug)

题目大意:

一个公司每个月盈利(s)或亏损(d)。统计人员没五个月统计一次,每次统计公司总是亏空(意思为这五个月的资金总和小于0)。一共进行了八次统计(1-5、2-6....8-12)。求公司一年最大的盈利值。

解题思路:

其实这题很水,但是还不错,主要是看懂题意即可,需要仔细多看几遍题意。

然后慢慢推出几种可能性:ssssdssssdss/sssddsssddss/ssdddssdddss/sddddsddddsd(尤其注意这一组每次统计必须个月亏损)。

代码:

 1 #include<cstdio>
2 #include<cmath>
3 #include<cstring>
4 #include<iostream>
5 #include<algorithm>
6
7 using namespace std;
8
9 int main()
10 {
11 int s,d;
12 while(scanf("%d%d",&s,&d)!=EOF)
13 {
14 int sum=-1;
15 if (4*s-d<=0)
16 sum=10*s-2*d;
17 else if (3*s-2*d<=0)
18 sum=8*s-4*d;
19 else if (2*s-3*d<=0)
20 sum=6*s-6*d;
21 else if (s-4*d<=0)
22 sum=3*s-9*d;
23 if (sum<0)
24 printf("Deficit\n");
25 else
26 printf("%d\n",sum);
27 }
28 return 0;
29 }

  

时间: 2024-10-09 23:32:33

poj2586(Y2K Accounting Bug)的相关文章

poj2586 Y2K Accounting Bug(贪心)

转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj.org/problem?id=2586 Language: Default Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9979   Accepted: 4970 Description Accounting for Computer

Y2K Accounting Bug(poj2586)

题意: 有一个公司由于某个病毒使公司赢亏数据丢失,但该公司每月的 赢亏是一个定数,要么一个月赢利s,要么一月亏d.现在ACM只知道该公司每五个月有一个赢亏报表,而且每次报表赢利情况都为亏.在一年中这样的报表总共有8次(1到5,2到6,…,8到12),现在要编一个程序确定当赢s和亏d给出,并满足每张报表为亏的情况下,全年公司最高可赢利多少,若存在,则输出多多额,若不存在,输出"Deficit". 分析: 在保证连续5个月都亏损的前提下,使得每5个月中亏损的月数最少.          

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: 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

Y2K Accounting Bug(贪心)

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

POJ2586——Y2K Accounting Bug

Y2K Accounting Bug Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc. All what they remember is that MS Inc. posted a surplus or a deficit each month of

Y2K Accounting Bug(贪心)

Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10687   Accepted: 5349 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 / 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: 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