poj 2586 Y2K Accounting Bug(贪心算法,水题一枚)
#include <iostream>
using namespace std;
/*248K 32MS*/
int main()
{
int s,d;
while(cin>>s>>d)
{
int count=0;
for(int i=5;i>0;i--)
{
if(s*i<(5-i)*d)
{
count=i;
break;
}
} int total=s*count-d*(5-count);
total*=2; if(count>=2)
total+=2*s;
else
total+=count*s-(2-count)*d; if(total<0)
cout<<"Deficit"<<endl;
else
cout<<total<<endl;
}
}
水题 就不多说什么了,直接枚举就能ac
poj 2586 Y2K Accounting Bug(贪心算法,水题一枚)的更多相关文章
- poj 2586 Y2K Accounting Bug (贪心)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8678 Accepted: 428 ...
- 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
题目地址:http://poj.org/problem?id=2586 /* 题意:某公司要统计全年盈利状况,对于每一个月来说,如果盈利则盈利S,如果亏空则亏空D. 公司每五个月进行一次统计,全年共统 ...
- 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: 10674 Accepted: 53 ...
- [POJ 2586] Y2K Accounting Bug (贪心)
题目链接:http://poj.org/problem?id=2586 题目大意:(真难读懂啊)给你两个数,s,d,意思是MS公司每个月可能赚钱,也可能赔钱,如果赚钱的话,就是赚s元,如果赔钱的话,就 ...
- POJ 2586 Y2K Accounting Bug(贪心)
题目连接:http://poj.org/problem?id=2586 题意:次(1-5.2-6.3-7.4-8.5-9.6-10.7-11.8-12),次统计的结果全部是亏空(盈利-亏空<0) ...
- POJ - 2586 Y2K Accounting Bug (找规律)
Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for ...
随机推荐
- 学习算法-基数排序(radix sort)卡片分类(card sort) C++数组实现
基数排序称为卡片分类,这是一个比较早的时间越多,排名方法. 现代计算机出现之前,它已被用于排序老式打孔卡. 说下基数排序的思想.前面我有写一个桶式排序,基数排序的思想是桶式排序的推广. 桶式排序:ht ...
- POJ - 1422 Air Raid 二分图最大匹配
题目大意:有n个点,m条单向线段.如今问要从几个点出发才干遍历到全部的点 解题思路:二分图最大匹配,仅仅要一条匹配,就表示两个点联通,两个点联通仅仅须要选取当中一个点就可以,所以有多少条匹配.就能够减 ...
- 在WPF使用FolderBrowserDialog和OpenFileDialog
原文 在WPF使用FolderBrowserDialog和OpenFileDialog 相信习惯以前winform开发的朋友们都对FolderBrowserDialog和OpenFileDialog这 ...
- Fedora 17 下安装codeblocks
Fedora 17 下安装codeblocks: 1.直接从yum源安装: sudo yum install codeblocks 2.源码安装 ...
- Linux chmod权限管理需要小心的地方
档案的权限管理和简单,比如chmod 775 /tmp/test.sh 另外使用chmod +w /tmp/test.sh,会给档案的拥有者,群组,其他人的权限都加上了可编辑.这样就有安全隐患了.所以 ...
- cocos2dx+lua编译Android项目
一.简单介绍 cocos2dx版本号:3.2 二.问题及解决方式 1.为项目开启Native支持,把项目转为C++项目. 1>.项目开启C++ Native支持,操作例如以下图 watermar ...
- JS - 鼠标经过边框旋转
*右侧为鼠标经过时效果. 下载地址:http://www.lanrentuku.com/js/tupian-1200.html
- JS - 图片放大器
下载地址:http://www.lanrentuku.com/js/tupian-1170.html
- 猿取向的规划设计模式 ——GoF《设计模式》阅读摘要(零)
这个话题是很奇怪,设计模式是引导程序的设计不是模仿什么软件?呃.我的意思是,这是 面"对象"相对的设计模式. 我曾见过有人写<给妻子解释设计模式>,这样的把计算机中的思 ...
- Swift - 可选类型说明
可选类型是Swift的一个特色.它表示一个变量有可能有值,也可能没有值(nil). 声明的方式是“数据类型+问号”. 而当要使用一个可选类型的变量是,要在后面加感叹号“!”. 1 2 3 4 5 6 ...