Fruit Feast

题目描述

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!

输入

The first (and only) line has three integers T, A, and B.

输出

 A single integer, representing the maximum fullness Bessie 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的更多相关文章

  1. USACO 2015 December Contest, Gold Problem 2. Fruit Feast

    Problem 2. Fruit Feast 很简单的智商题(因为碰巧脑出来了所以简单一,一 原题: Bessie has broken into Farmer John's house again! ...

  2. Fruit Feast(暴力)(动态规划)

    Fruit Feast 时间限制: 1 Sec  内存限制: 64 MB提交: 64  解决: 18[提交][状态][讨论版] 题目描述 Bessie has broken into Farmer J ...

  3. bzoj4393: [Usaco2015 Dec]Fruit Feast

    题意: T,A,B.T是上限.A和B可以随意吃但是不能超过T.有一次将吃的东西/2的机会.然后可以继续吃,不能超过T.问最多可以吃多少. =>我们先处理不能/2可以吃到哪些.然后弄个双指针扫一扫 ...

  4. P4817 [USACO15DEC]Fruit Feast 水果盛宴

    P4817 [USACO15DEC]Fruit Feast 水果盛宴 现在Bessie的饱食度为 00 ,她每吃一个橙子,饱食度就会增加 AA :每吃一个柠檬,饱食度就会增加 BB .Bessie还有 ...

  5. BZOJ 4393: [Usaco2015 Dec]Fruit Feast

    DP #include<cstdio> using namespace std; int T,A,B,F[5000005],G[5000005]; int main(){ scanf(&q ...

  6. P4817 Fruit Feast G

    最开始拿到这道题的时候,题目中其实只规定了两种水果的饱食度,可以理解成价值或是重量,在不超过T的情况求最大值.第一眼看过去感觉就是装箱问题(背包),只不过这道题用的是完全背包,但是考虑到喝水的情况,做 ...

  7. bzoj Usaco补完计划(优先级 Gold>Silver>资格赛)

    听说KPM初二暑假就补完了啊%%% 先刷Gold再刷Silver(因为目测没那么多时间刷Silver,方便以后TJ2333(雾 按AC数降序刷 ---------------------------- ...

  8. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  9. 【Cocos2d-x for WP8 学习整理】(2)Cocos2d-Html5 游戏 《Fruit Attack》 WP8移植版 开源

    这一阵花了些时间,把 cocos2d-html5 里的sample 游戏<Fruit Attack>给移植到了WP8上来,目前已经实现了基本的功能,但是还有几个已知的bug,比如WP8只支 ...

随机推荐

  1. 在centos中配置maven

    为了服务于jenkins,准备安装maven 首先在官网下载最新版本的maven,我此时的版本为apache-maven-3.3.9-bin.tar.gz 把该文件移到到/usr/local下 进行解 ...

  2. Ansible6:Playbook简单使用【转】

    ansbile-playbook是一系列ansible命令的集合,利用yaml 语言编写.playbook命令根据自上而下的顺序依次执行.同时,playbook开创了很多特性,它可以允许你传输某个命令 ...

  3. perl的package和module

    来源: http://www.cnblogs.com/itech/archive/2010/03/23/1692836.html 一 package 1) package 相当于C++中的namesp ...

  4. 更改JFram标题栏图标

    方式一: package com.swing.test; import javax.swing.ImageIcon; import javax.swing.JFrame; public class a ...

  5. flex超链接

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  6. 【C#】HTTP请求GET,POST(远程证书失效)

    HTTP定义了与服务器交互的不同方法,基本方法有GET,POST,PUT,DELETE,分别对于查,该,增,删.一般情况下我们只用到GET和POST,其他两种都也可以用GET和POST来实现,很多浏览 ...

  7. 5.1 timestamp数据类型默认值

    5.1 不支持同一张表中有多个tmiestamp类型字段的默认值为current_time,  5.6版本无此问题

  8. Sql Server异常捕获 try catch

    declare @num int begin try end try begin catch select ERROR_LINE() as 错误行数, ERROR_MESSAGE() as 错误消息 ...

  9. HDU 2255 奔小康赚大钱 KM算法的简单解释

    KM算法一般用来寻找二分图的最优匹配. 步骤: 1.初始化可行标杆 2.对新加入的点用匈牙利算法进行判断 3.若无法加入新编,修改可行标杆 4.重复2.3操作直到找到相等子图的完全匹配. 各步骤简述: ...

  10. 设计模式-中介者模式(Mediator)

    /***中介者模式在消息队列中的应用*/package test.mediator; public abstract class Message { private Messages messages ...