您的位置:首页 > 其它

526C - Om Nom and Candies

2015-04-05 09:46 405 查看
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#pragma comment(linker, "/STACK:102400000,102400000")
#define ll __int64

using namespace std;

int main(){
ll c, hr, hb, wr, wb;
while (scanf("%I64d%I64d%I64d%I64d%I64d",&c,&hr,&hb,&wr,&wb) != EOF){
ll ans = 0;
for (int i = 0; i<1000001; i++){
if (c - wr*i < 0) break;
ans = max(ans, hr*i + (c-wr*i) / wb * hb);
}

for (int i = 0; i<1000001; i++){
if (c - wb*i < 0) break;
ans = max(ans, hb*i + (c-wb*i) / wr * hr);
}

printf("%I64d\n",ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: