贪心 --- Y2K Accounting Bug
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 9691 | Accepted: 4838 |
Description
All what they remember is that MS Inc. posted a surplus or a deficit
each month of 1999 and each month when MS Inc. posted surplus, the
amount of surplus was s and each month when MS Inc. posted deficit, the
deficit was d. They do not remember which or how many months posted
surplus or deficit. MS Inc., unlike other companies, posts their
earnings for each consecutive 5 months during a year. ACM knows that
each of these 8 postings reported a deficit but they do not know how
much. The chief accountant is almost sure that MS Inc. was about to post
surplus for the entire year of 1999. Almost but not quite.
Write a program, which decides whether MS Inc. suffered a deficit
during 1999, or if a surplus for 1999 was possible, what is the maximum
amount of surplus that they can post.
Input
Output
each line of input, output one line containing either a single integer
giving the amount of surplus for the entire year, or output Deficit if
it is impossible.
Sample Input
59 237
375 743
200000 849694
2500000 8000000
Sample Output
116
28
300612
Deficit
【题目来源】
【题目大意】
有一家公司,每5个月的营销额总是亏损的,现在给你两个数字,分别表示这个公司每个月可能的盈利额或亏损额,现在要你求这个公司满足每5个月总是亏损的
条件,一年下来这个公司可能盈利的最大值,若为负,则输出"Deficit".
【题目分析】
一个简单的贪心,只要我们在判断的时候首先考虑盈利额最大的,按照盈利额减少的情况来判断,这就满足了贪心的求解方法。
#include<cstdio>
int main()
{
int s,d,t;
while(~scanf("%d%d",&s,&d))
{
if(*s-d<) t=*s-*d;
else if(*s-*d<) t=*s-*d;
else if(*s-*d<) t=*s-*d;
else if(s-*d<) t=*s-*d;
else t=-;
if(t<)
printf("Deficit\n");
else printf("%d\n",t);
}
return ;
}
贪心 --- Y2K Accounting Bug的更多相关文章
- 贪心 POJ 2586 Y2K Accounting Bug
题目地址:http://poj.org/problem?id=2586 /* 题意:某公司要统计全年盈利状况,对于每一个月来说,如果盈利则盈利S,如果亏空则亏空D. 公司每五个月进行一次统计,全年共统 ...
- poj2586 Y2K Accounting Bug(贪心)
转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj.org/problem?id=2586 ------ ...
- poj 2586 Y2K Accounting Bug (贪心)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8678 Accepted: 428 ...
- POJ 2586:Y2K Accounting Bug(贪心)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10024 Accepted: 4990 D ...
- POJ 2586 Y2K Accounting Bug 贪心 难度:2
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10537 Accepted: 52 ...
- Y2K Accounting Bug(贪心)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10945 Accepted: 54 ...
- [POJ2586]Y2K Accounting Bug
[POJ2586]Y2K Accounting Bug 试题描述 Accounting for Computer Machinists (ACM) has sufferred from the Y2K ...
- POJ2586——Y2K Accounting Bug
Y2K Accounting Bug Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K ...
- poj 2586 Y2K Accounting Bug
http://poj.org/problem?id=2586 大意是一个公司在12个月中,或固定盈余s,或固定亏损d. 但记不得哪些月盈余,哪些月亏损,只能记得连续5个月的代数和总是亏损(<0为 ...
随机推荐
- 由于找不到mingwm10.dll 由于找不到QtCore4.dll
出现如下错误: 由于找不到mingwm10.dll 由于找不到QtCore4.dll 解决办法 将qt库加入环境变量
- ECharts学习指南
1.了解ECharts ECharts简单说就是互联网开发程序过程中,后台数据库用以实现数据到图形的映射的一个插件. 具体来说一个使用 JavaScript 实现的开源可视化库,可以流畅的运行在PC和 ...
- JavaWeb 文件的上传、下载
文件上传 表单 <form action="HandlerServlet" method="post" enctype="multipart/f ...
- FPM Search里给查询条件加OVS搜索帮助
FPM里的OVS用法基本和WDA一致. 1,将OVS类添加到SEARCH.(可以单独写个类,因为这里为了方便,就和SEARCH放一起了) IF_FPM_GUIBB_OVS~HANDLE_PHASE_0 ...
- java修饰符在含义以及在eclipse下的显示
java四类修饰符的含义: public:公开的修饰符,没有调用限制,只用有该对象的路径,都可以调用. protected:在本类,同一个包,或子类中可以被调用. default(没有修饰符):在同一 ...
- Centos6.5硬盘故障修复
以企业Centos6.5Linux为案例来修复系统,步骤如下: (1)远程备份本地其他重要数据,出现只读文件系统,需要先备份其他重要数据基于rsync|scp远程备份,其中/data为源目录,/dat ...
- dapi 基于Django的轻量级测试平台三 接口关联
QQ群: GitHub:https://github.com/yjlch1016/dapi 一.接口关联思路: 在接口测试中, 很多场景下, 上一个接口的出参要作为下一个接口的入参, 即上一个接口的响 ...
- AMD 锐龙三代系列台式机处理器(台积电7纳米工艺)
AMD 锐龙 5 AMD 锐龙 5 3500X 处理器 6核心6线程,基准时钟频率3.6GHz,最大加速时钟频率4.1GHz,一级缓存384KB,总二级缓存3MB,三级缓存32MB,内存支持最高DDR ...
- Windows下Redis安装配置和使用注意事项
Windows下Redis安装配置和使用注意事项 一:下载 下载地址: https://github.com/microsoftarchive/redis/releases 文件介绍: 本文以3.2. ...
- 201871020225-牟星源 《面向对象程序设计(java)》课程学习进度条
<2019面向对象程序设计(java)课程学习进度条> 周次 (阅读/编写)代码行数 发布博客量/评论他人博客数量 课余学习时间(小时) 学习收获最大的程序 阅读或编译让我 第一周 25/ ...