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+10;
const int dis[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q,ll mo){ll f=1;while(q){if(q&1)f=f*p%mo;p=p*p%mo;q>>=1;}return f;}
int n,m,k,t,a,b,dp[maxn];
int main()
{int i,j;scanf("%d%d%d",&n,&a,&b);dp[0]=1;for(i=a;i<=n;i++)dp[i]|=dp[i-a];for(i=b;i<=n;i++)dp[i]|=dp[i-b];for(i=0;i<=n;i++)dp[i/2]|=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]==0;i--);printf("%d\n",i);//system ("pause");return 0;
}

转载于:https://www.cnblogs.com/dyzll/p/5759449.html

Fruit Feast相关推荐

  1. bzoj4393[Usaco2015 Dec]Fruit Feast*

    bzoj4393[Usaco2015 Dec]Fruit Feast 题意: 奶牛一开始饱胀值为0,上限为T.每个柠檬派提供a点饱胀值,每个橘子派提供b点饱胀值,有一次机会喝水,使得饱胀值div2.柠 ...

  2. bzoj 4393 Usaco Fruit Feast

    题目很明显的一道dp题目. 方程也不难推 dp[i][0]表示饱食度为i没喝水  dp[i][1]表示当前饱食度为i已经喝了水 #include <cstdio> #include < ...

  3. 洛谷——P4817 [USACO15DEC]Fruit Feast G

    非常简单的一个水题. 对于橙子和柠檬所能构成的饱和度的所有情况,可以用ax+by表示.看似要进行复杂度为O(n^2)的枚举,实际上,我们以先枚举x,再枚举y,将其复杂度降至O(n). #include ...

  4. luogu P4085 [USACO17DEC]Haybale Feast(尺取法 + 线段树)

    C.luogu P4085 [USACO17DEC]Haybale Feast 题目链接 直接开一个线段树维护即可. 注意开ll 线段树维护最大值.注意下标别写错了,比如tr[r] #include& ...

  5. FEAST:快速准确的微生物来源追溯工具

    不服就干!FEAST Source Tracker:快速准确的微生物来源追溯工具 百分百畅通版~ 广东省科学院 徐锐 环境微生物方向 最近帮老板做项目想试下source tracker,刚好看到公众号 ...

  6. 微生物群落来自哪里,我们说了算-FEAST or SourceTracker

    写在前面 最近由于老板有分析项目,我实在是进展缓慢,一直苦恼并艰难的探索和进展,所以很长时间没有和大家见面了,今天我为大家带来的source tracker分析,使用前一段时间刚出来的工具FEAST. ...

  7. Nature Methods:快速准确的微生物来源追溯工具FEAST

    文章目录 FEAST: 快速准确的微生物来源追溯工具 划重点 摘要 结果 图1. 方法比较 图2. 当前最先进方法的运行时间比较 图3. 1岁婴儿肠道微生物来源估计 图4. 厨房样品中末知来源的比例 ...

  8. 特征训练、预测一致性管理工具:开源项目Feast

    在机器学习的流程大体可以分成模型训练和模型服务两个阶段.无论是训练和服务阶段,其实都需要进行特征工程相关的工作,这块的技术挑战就是如何保证训练和预测过程中使用的特征是一致的.这个问题困扰了很多机器学习 ...

  9. 2011阿里巴巴程序设计公开赛 / 1002 Fruit Ninja

    某神的代码: #include<stdio.h> #define max(x,y) (x)>(y)?(x):(y) #define min(x,y) (x)<(y)?(x):( ...

最新文章

  1. 基于DOS命令打war包
  2. 用Java代码实现日志记录器_如何在此简单的Java日志记录实现中附加到日志文件? - java...
  3. Jenkins邮件配置,实现邮件发送策略(可实现每个Job对应不同的发送邮箱)
  4. python 数据流中的移动平均值_剑指Offer-41-数据流中的中位数
  5. JSP, C 写入文件添加BOM头实例
  6. CSDN积分获取方法
  7. 小程序毕设作品之微信小程序点餐系统毕业设计(5)任务书
  8. ACM 木材加工问题
  9. 卷积神经网络常见模块
  10. ,到底是买新房好还是二手房好?看完你就明白了!
  11. 2. TortoiseGit安装与配置
  12. “蔚来杯“2022牛客暑期多校训练营8
  13. 看了不会后悔的——SQL 面试题库
  14. 求n以内的所有素数(质数)个数
  15. 最赚钱的十大增值业务
  16. canoe的下载安装【亲测】
  17. 联想移动员工内幕消息,资深评论
  18. mdb java_java从mdb文件中读出数据
  19. SSM框架工作原理、作用及使用方法
  20. 工具推荐:4个小众Chrome插件,最后一个互联网人必备!

热门文章

  1. php 中的new,php new用法是什么
  2. Scratch之召开趣味运动会
  3. 养生四要:寡欲慎动法时却疾
  4. 因缘是诗意和困境的混杂
  5. 24个基本指标精粹讲解(14)--OBV
  6. 【Python系列2】Python变量类型和运算符 大全
  7. 《深入分析GCC 》——2.3 GNU binutils工具
  8. windows安全机制之登陆
  9. 和我一起学 Selenium WebDriver(1)——入门篇
  10. 新浪微博客户端开发之主界面实现