Poj_2586 Y2K Accounting Bug(数学)
来源:互联网 发布:网络直播营销方案 编辑:程序博客网 时间:2024/05/20 16:01
题意:
一家公司每五个月出一份财务报表,一年出8份(1-5,2-6,3-7...8-12)。对于该公司来说每个月要么亏损d元,要么盈利s。已知1999年该公司八份财务报表都显示亏损,问该公司全年可能不可能实现盈利,最大可能为多少?
思路:
最开始题意愣是没读懂。奇葩的一点在于每次亏损都是d,每次盈利都是s。那么把所有的情况枚举出来就行了。一共有以下五种情况:
ssssd ssssd ss
sssdd sssdd ss
ssddd ssddd ss
sdddd sdddd sd
ddddd ddddd dd
这里有一点贪心就是把亏损月尽量往后放,尽可能多出来盈利月。
代码实现:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#define LL long longusing namespace std;LL s,d;LL res;bool flag;int main(){ while( scanf("%I64d%I64d",&s,&d) != EOF ){ res = 0; if( s*4 < d ){ res = s*10-2*d; } else if( s*3 < 2*d ){ res = s*8-4*d; } else if( s*2 < 3*d ){ res = s*6-6*d; } else if( s < 4*d ){ res = s*3-9*d; } else{ res = -1; } if( res >= 0 ){ printf("%I64d\n",res); } else{ printf("Deficit\n"); } } return 0;}
0 0
- Poj_2586 Y2K Accounting Bug(数学)
- POJ_2586 Y2K Accounting Bug(贪心)
- poj_2586 Y2K Accounting Bug(贪心)
- Y2K Accounting Bug POJ2586
- poj2586 Y2K Accounting Bug
- POJ2586 Y2K Accounting Bug
- POJ Y2K Accounting Bug
- POJ2586 Y2K Accounting Bug
- POJ2586--Y2K Accounting Bug
- Y2K Accounting Bug
- poj2586 Y2K Accounting Bug
- POJ2586:Y2K Accounting Bug
- POJ2586 Y2K Accounting Bug
- poj2586--Y2K Accounting Bug
- Y2K Accounting Bug(贪心)
- POJ2586-Y2K Accounting Bug
- poj2586 Y2K Accounting Bug
- Y2K Accounting Bug
- 发布wex5到服务器步骤
- POJ 3155 Hard Life 已翻译
- 训练总结(大一下)
- JavaScript高级程序设计10--DOM2和DOM3
- POJ-2486-树形dp
- Poj_2586 Y2K Accounting Bug(数学)
- 丢失undo表空间后恢复
- colorhistogram.h
- java内部类
- Elasticsearch Terms Aggregation 根据某一项的聚合
- 4-基本布局+CSS样式属性+盒子模型
- cf 743D
- CodeForces-743D Chloe and pleasant prizes(树型dp)
- usaco Electric Fence