51nod 1548 欧姆诺姆和糖果
来源:互联网 发布:linux 模糊查找文件 编辑:程序博客网 时间:2024/06/09 23:39
XJB暴力跑一下。。。。感觉应该有更好的做法
#include<bits/stdc++.h>using namespace std;int main(){long long c,hr,wr,hb,wb,i,ans,limit=10000000;while(~scanf("%lld%lld%lld%lld%lld",&c,&hr,&hb,&wr,&wb)){ans=0;if(c/wb<limit){for(i=c/wb;i>=0;i--){ans=max(ans,((c-i*wb)/wr)*hr+i*hb);}}else if(c/wr<limit){for(i=c/wr;i>=0;i--){ans=max(ans,((c-i*wr)/wb)*hb+i*hr);}}else{if(hr*wb<hb*wr){swap(hr,hb);swap(wr,wb);}for(i=min(limit,c/wb);i>=0;i--){ans=max(ans,((c-i*wb)/wr)*hr+i*hb);}}printf("%lld\n",ans);}return 0;}
0 0
- 51NOD 1548 欧姆诺姆和糖果
- 51nod 1548 欧姆诺姆和糖果
- 【51nod】1548 欧姆诺姆和糖果
- 51Nod-1548-欧姆诺姆和糖果
- 51nod-1548:欧姆诺姆和糖果
- 1548 欧姆诺姆和糖果 51NOD
- 51nod 1548 欧姆诺姆和糖果 (思维 枚举)
- 51nod 1548 欧姆诺姆和糖果
- 515nod 1548 欧姆诺姆和糖果 【枚举】
- 51nod 1548 欧姆诺姆和糖果【思维+分类讨论】
- 51 nod 1548 欧姆诺姆和糖果(背包思维暴力写)@
- 51nod 1548欧姆诺姆和糖果(枚举优化)
- 欧姆诺姆和糖果
- 51Nod-1554-欧姆诺姆和项链
- 51NOD 1554 欧姆诺姆和项链 【kmp】
- 51nod1548-枚举&技巧&数学证明-欧姆诺姆和糖果
- 51nod卷积和
- P3793礼物和糖果
- ubuntu16.04安装kde桌面出错
- 浅谈JavaScript--Array数组的join()方法
- 文章标题
- C语言结构体与共用体(1)
- sort: 349. Intersection of Two Arrays \ 350. Intersection of Two Arrays II
- 51nod 1548 欧姆诺姆和糖果
- android ContentProvider内容提供者
- poj 2367 拓扑排序
- MySQL 存储过程相互调用举例
- uva 11463 Commandos
- Spring Web MVC框架(三) 异步处理
- [linux]当在unix系统中输入任何命令时导致command not found情况
- MySQL存错过程动态执行sql的方式来返回结果集
- 一个简易而有趣的爬虫——对草榴帖子的爬取