背包--nkoj3609【USACO 2015 Dec Gold】Fruit Feast
来源:互联网 发布:利用php漏洞进行提权 编辑:程序博客网 时间:2024/06/05 11:35
【USACO 2015 Dec Gold】Fruit Feast
Description
Bessie has broken into Farmer John's house again! She has discovered a pile of lemons and a pile of oranges in the kitchen (effectively an unlimited number of each), and she is determined to eat as much as possible.
Bessie has a maximum fullness of T (1≤T≤5,000,000). Eating an orange increases her fullness by A, and eating a lemon increases her fullness by B (1≤A,B≤T). Additionally, if she wants, Bessie can drink water at most one time, which will instantly decrease her fullness by half (and will round down).
Help Bessie determine the maximum fullness she can achieve!
贝西正在搞破坏,她在厨房里发现了一堆柠檬派和一堆橘子派,打算尽量多吃一点。
贝西能够达到的最大饱度为T(1≤T≤5,000,000)。每一份橘子派会增加A的饱度,每一份柠檬派会增加B的饱度(1≤A,B≤T)。她可以在吃的过程中至多喝一次水,喝水之后她的饱度会减半(向下取整)。
帮贝西算出她能够达到的最大饱度。
Input
The first (and only) line has three integers T, A, and B.
第一行三个整数T,A,B。
Output
A single integer, representing the maximum fullness Bessie can achieve.
输出一个整数,表示贝西可以达到的最大饱度。
Sample Input
8 5 6
Sample Output
8
水题:不解释,背包背包
#include<cstdio>#include<iostream>#include<algorithm>#include<queue>#include<stack>using namespace std;bool f[5000005];int w[3];int main(){int t,a,b,i,j;scanf("%d%d%d",&t,&a,&b);if(t%a==0||t%b==0){cout<<t;return 0;}w[1]=a;w[2]=b;f[0]=true;for(i=1;i<=2;i++){for(j=w[i];j<=t;j++){if(f[j-w[i]])f[j]=true;}}if(f[t]){cout<<t;return 0;}else{for(i=1;i<=t;i++){if(f[i])f[i/2]=true;}f[0]=false;for(i=1;i<=2;i++){for(j=w[i];j<=t;j++){if(f[j-w[i]])f[j]=true;}}}for(i=t;i>=0;i--){if(f[i]){cout<<i<<endl;return 0;}}}
- 背包--nkoj3609【USACO 2015 Dec Gold】Fruit Feast
- bzoj4393【Usaco2015 Dec】Fruit Feast
- bzoj4393[Usaco2015 Dec]Fruit Feast DP
- usaco-2007-Dec-Gold: 队列变换 (bclgold)
- 【USACO 2011 Dec Gold 】简化农场
- 【Usaco 2007 Dec gold】队列变换
- Usaco 2007 Dec gold 队列变换
- usaco 2011 Dec Gold(Grass Planting-树链剖分第一题)
- BZOJ1591 USACO 2008 Dec Gold 4.Largest Fence Solution
- Feast Coins(多重背包)
- 【BZOJ1589】【USACO 2008 Dec Gold】 1.Trick or Treat on the Farm 基环树裸DP、
- BZOJ 2097 USACO 2010 Dec Gold Exercise 奶牛健美操 二分答案 树形DP 贪心
- BZOJ 2606 USACO 2008 Dec Gold 2.Secret Message 字典树
- bzoj1774 USACO 2009 Dec Gold 2.Cow Toll Paths 过路费 翻译+题解
- BZOJ 4393: [Usaco2015]Fruit Feast|离散化|暴力
- bzoj3939 【USACO 2015 FEB GOLD 】cow hopscotch
- P3213【USACO 2015 Jan Gold】牧草鉴赏家
- USACO 2015 Dec Platinum 1.Max Flow
- Windows下搭建IOS开发环境(一)
- Lazy inflate之ViewStub
- 第五周项目二-游戏中的角色类(2)
- yii2.0如何获取当前的控制器名与方法名
- leetcode之delete Node in a Linked List
- 背包--nkoj3609【USACO 2015 Dec Gold】Fruit Feast
- 化繁为简 如何向老婆解释MapReduce?
- 正则表达式带有双引号 如何去掉 js里用
- Linked List Cycle
- centos7安装mate
- AnimMontage(中文翻译)——UE4官方文档
- 中国县级和以下行政区编码,2013年,sql文件
- hdu1124
- Android调用相机无法执行onActivityResult或data为null