POJ 2586 贪心+枚举】的更多相关文章

Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15626   Accepted: 7843 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc…
题目地址:http://poj.org/problem?id=2586 /* 题意:某公司要统计全年盈利状况,对于每一个月来说,如果盈利则盈利S,如果亏空则亏空D. 公司每五个月进行一次统计,全年共统计8次(1-5.2-6.3-7.4-8.5-9.6-10.7-11.8-12), 已知这8次统计的结果全部是亏空(盈利-亏空<0).题目给出S和D,判断全年是否能盈利, 如果能则求出盈利的最大值,如果不能盈利则输出Deficit 贪心 or 枚举 1. 贪心抓住亏损的月尽量在5个月的后面,这样可以被…
看题传送门:http://poj.org/problem?id=1018 题目大意: 某公司要建立一套通信系统,该通信系统需要n种设备,而每种设备分别可以有m个厂家提供生产,而每个厂家生产的同种设备都会存在两个方面的差别:带宽bandwidths 和 价格prices. 现在每种设备都各需要1个,考虑到性价比问题,要求所挑选出来的n件设备,要使得B/P最大. 其中B为这n件设备的带宽的最小值,P为这n件设备的总价. 思路: 贪心+枚举 要使得B/P最大,则B应该尽量大,而P尽量小. 可以按照价格…
The Fortified Forest Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6198   Accepted: 1744 Description Once upon a time, in a faraway land, there lived a king. This king owned a small collection of rare and valuable trees, which had been…
题目链接:http://poj.org/problem?id=2586 题目大意:(真难读懂啊)给你两个数,s,d,意思是MS公司每个月可能赚钱,也可能赔钱,如果赚钱的话,就是赚s元,如果赔钱的话,就是陪d元.现在告诉你只要是连续的5个月,就亏钱(亏多少不知道),问你MS公司全年能够赚多少钱,如果赚不了钱的话,就输出“Deficit” 贪心:我们说,输出的最终结果是f(x,y)=x*s-y*d,也就是说现在要求得x,y使得f(x,y)具有最大值. 当s,d,x+y给定时,x越大,则赚的钱越多.…
Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8678   Accepted: 4288 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc.…
题目连接:http://poj.org/problem?id=2586 题意:次(1-5.2-6.3-7.4-8.5-9.6-10.7-11.8-12),次统计的结果全部是亏空(盈利-亏空<0).题目给出S和D,判断全年是否能盈利,如果能则求出盈利的最大值,如果不能盈利则输出Deficit 解析: 全年的盈亏情况可以由前五个月直接决定1.若SSSSD亏空,那么全年最优情况为SSSSDSSSSDSS 2.若SSSDD亏空,那么全年最优情况为SSSDDSSSDDSS 3.若SSDDD亏空,那么全年最…
Description Bessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fellow cows formed a new university called The University of Wisconsin-Farmside,"Moo U" for short. Not wish…
#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) tota…
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10024 Accepted: 4990 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc. Al…