Fruit Feast
Fruit Feast
题目描述
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!
输入
输出
样例输入
8 5 6
样例输出
8
分析:完全背包,注意喝水时的更新;
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define ll long long
#define pi acos(-1.0)
const int maxn=5e6+;
const int dis[][]={{,},{-,},{,-},{,}};
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q,ll mo){ll f=;while(q){if(q&)f=f*p%mo;p=p*p%mo;q>>=;}return f;}
int n,m,k,t,a,b,dp[maxn];
int main()
{
int i,j;
scanf("%d%d%d",&n,&a,&b);
dp[]=;
for(i=a;i<=n;i++)dp[i]|=dp[i-a];
for(i=b;i<=n;i++)dp[i]|=dp[i-b];
for(i=;i<=n;i++)dp[i/]|=dp[i];
for(i=a;i<=n;i++)dp[i]|=dp[i-a];
for(i=b;i<=n;i++)dp[i]|=dp[i-b];
for(i=n;dp[i]==;i--);
printf("%d\n",i);
//system ("pause");
return ;
}
Fruit Feast的更多相关文章
- USACO 2015 December Contest, Gold Problem 2. Fruit Feast
Problem 2. Fruit Feast 很简单的智商题(因为碰巧脑出来了所以简单一,一 原题: Bessie has broken into Farmer John's house again! ...
- Fruit Feast(暴力)(动态规划)
Fruit Feast 时间限制: 1 Sec 内存限制: 64 MB提交: 64 解决: 18[提交][状态][讨论版] 题目描述 Bessie has broken into Farmer J ...
- bzoj4393: [Usaco2015 Dec]Fruit Feast
题意: T,A,B.T是上限.A和B可以随意吃但是不能超过T.有一次将吃的东西/2的机会.然后可以继续吃,不能超过T.问最多可以吃多少. =>我们先处理不能/2可以吃到哪些.然后弄个双指针扫一扫 ...
- P4817 [USACO15DEC]Fruit Feast 水果盛宴
P4817 [USACO15DEC]Fruit Feast 水果盛宴 现在Bessie的饱食度为 00 ,她每吃一个橙子,饱食度就会增加 AA :每吃一个柠檬,饱食度就会增加 BB .Bessie还有 ...
- BZOJ 4393: [Usaco2015 Dec]Fruit Feast
DP #include<cstdio> using namespace std; int T,A,B,F[5000005],G[5000005]; int main(){ scanf(&q ...
- P4817 Fruit Feast G
最开始拿到这道题的时候,题目中其实只规定了两种水果的饱食度,可以理解成价值或是重量,在不超过T的情况求最大值.第一眼看过去感觉就是装箱问题(背包),只不过这道题用的是完全背包,但是考虑到喝水的情况,做 ...
- bzoj Usaco补完计划(优先级 Gold>Silver>资格赛)
听说KPM初二暑假就补完了啊%%% 先刷Gold再刷Silver(因为目测没那么多时间刷Silver,方便以后TJ2333(雾 按AC数降序刷 ---------------------------- ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- 【Cocos2d-x for WP8 学习整理】(2)Cocos2d-Html5 游戏 《Fruit Attack》 WP8移植版 开源
这一阵花了些时间,把 cocos2d-html5 里的sample 游戏<Fruit Attack>给移植到了WP8上来,目前已经实现了基本的功能,但是还有几个已知的bug,比如WP8只支 ...
随机推荐
- VO , PO , BO , QO, DAO ,POJO
VO , PO , BO , QO, DAO ,POJO, O/R Mapping 是 Object Relational Mapping (对象关系映射)的缩写.通俗点讲,就是将对象与关系数据库绑定 ...
- sql server 2000/2005递归
/* 递归查询 塗聚文---SQL Server 2005环境下的实现: */--生成测试数据 create table Dept(ID int,ParentID int,msg varchar(20 ...
- 在Linux服务器上增加硬盘没那么简单【转】
运维案例:HP服务器,LINUX系统在保障数据的前提下扩展/home分区 部门需求:研发部门提出需要在现有的服务器上扩容磁盘空间,以满足开发环境的磁盘需求.现有空间1.6T需要增加到2T. 需求调查分 ...
- PHP字符串函数试题
Ctrl+A查看答案 1.把ASCII字符的字符串转换为十六进制值的函数是什么?答:bin2hex($string),例如bin2hex('ab') = 6162 2.ASCII码转字符,字符转ASC ...
- Unable to chmod /system/build.prop.: Read-only file system
Unable to chmod /system/build.prop.: Read-only file system 只读文件系统 所以需要更改 使用下面的命令 mount -o remount,rw ...
- 重写AlertView(用block)
@interface AlertView : UIView @property (nonatomic,copy) void(^block)(UIColor *color); - (id)initWit ...
- 国内的cdn
测试了一下,百度的非常快 ----------------------------------------------------------------------- 原文:https://www. ...
- JPA 系列教程6-单向多对多
JPA中的@ManyToMany @ManyToMany注释表示模型类是多对多关系的一端. @JoinTable 描述了多对多关系的数据表关系. name 属性指定中间表名称 joinColumns ...
- 关于tag,viewWithTag
iOS SDK内置了一套搜寻机制,可通过tag来查找子视图. **苹果公司很少给子视图设置tag.笔者所知范围的唯一例外出现在UIAlertView中,该类会给按钮分别设置值为1.2的标签 viewW ...
- iOS 6 Passbook 入门 1/2
http://www.raywenderlich.com/zh-hans/23066/ios-6-passbook-%E5%85%A5%E9%97%A8-12 iOS 6 Passbook 入门 1/ ...