Henu ACM Round#19 E Om Nom and Candies

Posted Visitor

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Henu ACM Round#19 E Om Nom and Candies相关的知识,希望对你有一定的参考价值。

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

紫书上的原题; [链接](http://www.cnblogs.com/AWCXV/p/8036874.html)

【代码】

#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 1e5;

ll m,c1,c2,v1,v2;

int main()
{
    #ifdef LOCAL_DEFINE
        freopen("rush_in.txt","r",stdin);
    #endif
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> m >> c1 >> c2 >> v1 >> v2;
    ll ans = 0;
    if (m/v1 <=(int)1e7){
        for (int i = 0;i <= m/v1;i++){
            ll temp = 1LL*i*c1;
            ll temp2 = 1LL*c2*((m-1LL*i*v1)/v2);
            ans= max(ans,temp+temp2);
        }
    }else if (m/v2<=(int)1e7){
        for (int i = 0;i <= m/v2;i++){
            ll temp = 1LL*i*c2;
            ll temp2 = 1LL*c1*((m-i*v2)/v1);
            ans= max(ans,temp+temp2);
        }
    }else{
        if (c1*v2>c2*v1){
            for (int i = 0;i<=v1 ;i++){
                ll now = 1LL*i*c2;
                ll V = 1LL*i*v2;
                if (m-V<0) break;
                ll now1 = 1LL*((m-V)/v1)*c1;
                ans = max(ans,now+now1);
            }
        }else{
            for (int i = 0;i<=v2 ;i++){
                ll now = 1LL*i*c1;
                ll V = 1LL*i*v1;
                if (m-V<0) break;
                ll now1 = 1LL*((m-V)/v2)*c2;
                ans = max(ans,now+now1);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

以上是关于Henu ACM Round#19 E Om Nom and Candies的主要内容,如果未能解决你的问题,请参考以下文章

Henu ACM Round#19 C Developing Skills

Henu ACM Round#19 B Luxurious Houses

Henu ACM Round#19 A Vasya the Hipster

Henu ACM Round#19 D Points on Line

Henu ACM Round#15 E A and B and Lecture Rooms

Henu ACM Round#20 EStar