POJ 2856 Y2K Accounting Bug【简单暴力】
链接:
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 8472 | Accepted: 4185 |
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
Sample Input
59 237
375 743
200000 849694
2500000 8000000
Sample Output
116
28
300612
Deficit
Source
题目:

思路:
code:
#include<stdio.h>
int main()
{
int s, d;
while(scanf("%d%d", &s,&d) != EOF)
{
int ans = -1;
if(4*s < d) ans = 10*s-2*d; //ssssd
else if(3*s < 2*d) ans = 8*s-4*d; //sssdd
else if(2*s < 3*d) ans = 6*s-6*d; //ssddd
else if(s < 4*d) ans = 3*s-9*d; //sdddd
if(ans < 0) printf("Deficit\n");
else printf("%d\n", ans);
//for(int i = 1; i <= 12; i++) printf("%d\n", i*s-(12-i)*d);
} return 0;
}
POJ 2856 Y2K Accounting Bug【简单暴力】的更多相关文章
- 贪心 POJ 2586 Y2K Accounting Bug
题目地址:http://poj.org/problem?id=2586 /* 题意:某公司要统计全年盈利状况,对于每一个月来说,如果盈利则盈利S,如果亏空则亏空D. 公司每五个月进行一次统计,全年共统 ...
- POJ 286 Y2K Accounting Bug【简单暴力】
链接: http://poj.org/problem?id=2586 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26733#probl ...
- poj 2586 Y2K Accounting Bug
http://poj.org/problem?id=2586 大意是一个公司在12个月中,或固定盈余s,或固定亏损d. 但记不得哪些月盈余,哪些月亏损,只能记得连续5个月的代数和总是亏损(<0为 ...
- 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: 10674 Accepted: 53 ...
- POJ 2586 Y2K Accounting Bug 贪心 难度:2
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10537 Accepted: 52 ...
- POJ 2586 Y2K Accounting Bug(枚举大水题)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10674 Accepted: 53 ...
- POJ - 2586 Y2K Accounting Bug (找规律)
Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for ...
- [POJ 2586] Y2K Accounting Bug (贪心)
题目链接:http://poj.org/problem?id=2586 题目大意:(真难读懂啊)给你两个数,s,d,意思是MS公司每个月可能赚钱,也可能赔钱,如果赚钱的话,就是赚s元,如果赔钱的话,就 ...
随机推荐
- yarn Fairscheduler与Capacityscheduler
Capacityscheduler Capacityscheduler允许多个组织共享整个集群,每个组织可以获得集群的一部分计算能力.通过为每个组织分配专门的队列,然后再为每个队列分配一定的集群资源, ...
- CountDownLatch模拟高并发测试代码
直接上代码进行验证吧 /** * 通过countdownlatch的机制,来实现并发运行 * 模拟200个并发测试 * @author ll * @date 2018年4月18日 下午3:55:59 ...
- ECSHOP搜索框文字点击消失
<input name="keywords" type="text" id="keyword" value="黄山金银币&q ...
- spring aop中的propagation(传播属性)的7种配置的意思
1.前言. 在声明式的事务处理中,要配置一个切面,即一组方法,如 <tx:advice id="txAdvice" transaction-manager="t ...
- MyISAM和InnoDB存储引擎的差别
1.MyISAM不支持事务处理等高级处理,而InnoDB支持. 2.MyISAM强调的是性能,速度更快,而InnoDB提供事务支持以及外键等高级数据库功能. 3.MyISAM读性能比InnoDB强非常 ...
- 娓娓道来c指针 (2)内存分配
(2)内存分配 c语言中描写叙述变量的时候经常使用的两个用语 1.作用域:也叫可见域,指的是变量的作用范围. 在哪个范围内.该变量是可见的.能够使用的. 2.生存期:也叫存储期.指的是变量从创建到销毁 ...
- Tomcat Https配置
一.生成KeyStore 打开命令行,输入:keytool -genkey -alias tomcat_server -keyalg RSA -storepass jimmypwd -validity ...
- mvc Ajax 跨域请求
js端: $.ajax({ type : "get", async : false, url :url, data: 'bid=0&xingming=' + uName + ...
- Paxos 学习总结
近期学习了分布式领域的重要算法Paxos,这里罗列下关键点当作总结.自己水平有限,难免存在谬误,恳请读者指正.本篇不包含Paxos的基本理论介绍.Paxos基础能够參考以下的学习资料章节. 1 Pax ...
- Spring学习二----------IOC及Bean容器
© 版权声明:本文为博主原创文章,转载请注明出处 接口 用于沟通的中介物的抽象化 实体把自己提供给外界的一种抽象化说明,用以由内部操作分离出外部沟通方法,使其能被修改内部而不影响外界其他实体与其交互的 ...