//poj2586 读题好难,我都怀疑自己英语了。。。
//给你盈利和亏损额度,每5个月发布一次,必须总的是亏的,但是保证亏的最少 1-5 2-6...
//求这样下去12个月的最大盈利是多少 ?(虽然5个月都会亏, 但是连续下来时有可能盈利的)
//wa了一次,没有考虑到全年都是亏损的情况
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main()
{
int s, d;
while(cin>>s>>d)
{
int x, y;
for(int i = 4; i >= 0; i--)
{
//5个月一次循环的样子,所以5个月亏n次,代表了12个月会亏 2n次
x = i;
y = 5 - i;
if(s * x < d * y)
{
break;
}
}
int surplus = 0;
if(x != 1 && x != 0)
surplus = s * (12-2*y) - d * y * 2;
else if(x == 1)
surplus = s * 3 - 9 * d;
else if(x == 0)
surplus = -12 * d;
if(surplus > 0)
{
cout<<surplus<<endl;
}
else
cout<<"Deficit"<<endl;
}
return 0;
}
poj2586
最新推荐文章于 2021-05-09 21:49:21 发布