贪心 --- 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为 ...
随机推荐
- XSS相关有效载荷及绕道的备忘录(下)| 文末有打包好的负载
前言: 今天发布的是下半部分 进入正题 过滤的绕过和一些奇异的有效载荷 大小写绕过 <sCrIpt>alert(1)</ScRipt> 绕过标签黑名单 <script x ...
- 某安全设备未授权访问+任意文件下载0day
具体是哪家就不说了,硬件盒子,主要检测病毒. payload如下: https://xxx.xxx.xxx.xxx/downTxtFile.php?filename=/etc/passwd 比较简单, ...
- 英语chrysopal金绿宝石chrysopal单词
chrysopal金绿宝石,也称金绿玉.化学成分为BeAl2O4.晶体属正交(斜方)晶系的氧化物矿物.它位列名贵宝石,具有四个变种:猫眼,变石,变石猫眼和金绿宝石晶体. 金绿宝石本身就是较稀少的矿物, ...
- spoon数据转换中文乱码(kettle)
(1) 查看mysql数据库是否为utf8(status) (2) 设置spoon (3) 文本打开spoon.bat,找到set OPT=%OPT% %PENTAHO_DI_JAVA_OPTIONS ...
- Python基础(二)--基本数据类型、格式化输出、基本运算符
一.基本数据类型 1.数字类型 #int整型 定义:age=10 #age=int(10) 用于标识:年龄,等级,身份证号,qq号,个数 #float浮点型 定义:salary=3.1 #salary ...
- 代数&数论趣题集萃
暑假总不能只学习平面几何.所以这里也收集一些有趣的代数题或数论题,同时记下解法的一些提示.给未来的自己复习参考用. 多图片预警(请注意流量) 目录: Part 0:其他(8) Part 1:不等式(1 ...
- 逆向破解之160个CrackMe —— 028
CrackMe —— 028 160 CrackMe 是比较适合新手学习逆向破解的CrackMe的一个集合一共160个待逆向破解的程序 CrackMe:它们都是一些公开给别人尝试破解的小程序,制作 c ...
- win10 任务栏上的工具栏,重启消失的解决方法
首先谈下 <任务栏的工具栏> 对于很多人来言,还是有可取性的 任务栏的工具栏对编程者的作用 一般来说,我们会经常查看某些API文档,虽然现在是联网也很方便,但如果都下载下来,整理到一个文件 ...
- 201871010109-胡欢欢《面向对象程序设计(java)》第二周学习总结
开头: 项目 内容 这个作业属于哪个课程 <任课教师博客主页链接> https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 <作业链接地 ...
- robotframework-selenium2library各个版本
https://github.com/robotframework/Selenium2Library/downloads