POJ 2586 Y2K Accounting Bug 贪心
来源:互联网 发布:网络歌曲《情醉》 编辑:程序博客网 时间:2024/05/21 08:56
看题传送门 :http://poj.org/problem?id=2586
题目大意:
一个公司在12个月中,每个月盈余s,或亏损d.
但记不得哪些月盈余,哪些月亏损,只能记得连续5个月的代数和总是亏损(<0为亏损),问全年是否可能盈利?若可能,输出可能最大盈利金额,否则输出“Deficit".
一年中只有8个连续的5个月,分别为1~5,2~6,…,8~12
亏损的时候尽量靠后排。
如:
5个月中有1个月亏损(安排在5和10)
5个月中有2个月亏损 (安排在4 5和9 10)
5个月中有3个月亏损 (安排在3 4 5和 8 9 10)
5个月中有4个月亏损 (安排在2 3 4 5和7 8 9 10)
5个月中有5个月亏损 (咳咳)
#include<cstdio>#include<iostream>using namespace std;int s,d,ans;void solve(){if(s*4<d)ans=s*10-d*2;else if(s*3<d*2)ans=s*8-d*4;else if(s*2<d*3)ans=s*6-d*6;else if(s*1<d*4)ans=s*3-d*9;else ans=-d*12;}int main(){while(scanf("%d%d",&s,&d)!=EOF){solve();if(ans<0)printf("Deficit\n");elseprintf("%d\n",ans);}}
- POJ 2586 Y2K Accounting Bug贪心
- POJ 2586 Y2K Accounting Bug 贪心
- poj 2586 Y2K Accounting Bug 贪心
- poj 2586 Y2K Accounting Bug (贪心)
- POJ 2586 Y2K Accounting Bug 贪心策略
- POJ 2586 Y2K Accounting Bug 贪心
- POJ 2586 Y2K Accounting Bug(贪心)
- POJ 2586:Y2K Accounting Bug:贪心法
- poj 2586 Y2K Accounting Bug (贪心)
- POJ 2586:Y2K Accounting Bug(贪心)
- POJ--2586:Y2K Accounting Bug (贪心)
- 【贪心】POJ-2586 Y2K Accounting Bug
- POJ 2586 Y2K Accounting Bug(贪心)
- poj 2586 Y2K Accounting Bug 【贪心】
- POJ 2586-Y2K Accounting Bug(贪心)
- POJ 2586 Y2K Accounting Bug 简单贪心
- POJ 2586 Y2K Accounting Bug(贪心)
- POJ 2586 Y2K Accounting Bug (贪心)
- OCP-1Z0-053-V12.02-189题
- 为什么要学习C语言
- zoj 3366 Light Bulb 三分
- 创建单链表的4种方式
- 使用spring 并加载模板发送Email 发邮件 java 模板
- POJ 2586 Y2K Accounting Bug 贪心
- C++ STL学习笔记2--String
- 关于嵌入式linux开发环境搭建-TFTP,SAMBA,NFS服务器的搭建
- POJ 1118 Lining Up
- 关于IOCP那些事
- 环境: Ogre 在 Visual Studio 2010 上的环境配置
- 一个球从100米高度自由落下
- 使用spring 并加载模板发送Email 发邮件 java 模板
- github backup