Y2K Accounting Bug&&贪心 ??

在这里插入图片描述
Sample Input

59 237
375 743
200000 849694
2500000 8000000

Sample Output

116
28
300612
Deficit

这个题的意思是有一个每五个月必有亏空的公司,它每个月盈利或亏损的数额是一样的,求出它每年最多盈利多少。
这个题开始根本没读懂题意T^T哪怕直接翻译成中文也没明白。。不知道5和8有啥关系
5和8的意思是1-5,2-6,3-7,4-8,5-9,6-10,7-11,8-12这8个连续的五个月。
在这里插入图片描述
我们要保证连续的五个月都要有亏损,而且一年的盈利尽可能的多。

代码

#include<iostream>
using namespace std;
int main()
{
    int s,d;
    while(cin>>s>>d)
    {
        int ans;
        if(d>4*s)
            ans=10*s-2*d;
        else if(2*d>3*s)
            ans=8*s-4*d;
        else if(3*d>2*s)
            ans=6*s-6*d;
        else if(4*d>s)
            ans=3*s-9*d;
        else
            ans = -1;
        if(ans>=0)
        cout<<ans<<endl;
        else
            cout<<"Deficit"<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43105110/article/details/89309826