zoukankan      html  css  js  c++  java
  • bzoj4393【Usaco2015 Dec】Fruit Feast

    4393: [Usaco2015]Fruit Feast

    Time Limit: 10 Sec  Memory Limit: 128 MB
    Submit: 81  Solved: 50
    [Submit][Status][Discuss]

    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!

    奶牛Bessie潜入了农夫约翰的家,她发现这里有无穷无尽的柠檬派和橘子派。

    Bessie的饱胀值一開始是0。且上限是T,每一个柠檬派能够提供A点饱胀值。每一个橘子派能够提供B点饱胀值。

    Bessie能够不断地吃东西,假设她的饱胀值没有超出T的话。同一时候,Bessie有一次喝水的机会,喝完后,她的饱胀值将降低一半(往下取整)。

    请计算出Bessie的饱胀值最多能够达到多少。

    Input

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

    Output

    A single integer, representing the maximum fullness Bessie can achieve.

    Sample Input

    8 5 6

    Sample Output

    8

    HINT

    Source




    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cstdlib>
    #include<algorithm>
    #include<queue>
    #define F(i,j,n) for(int i=j;i<=n;i++)
    #define D(i,j,n) for(int i=j;i>=n;i--)
    #define ll long long
    #define pa pair<int,int>
    #define maxn 5000100
    #define inf 1000000000
    using namespace std;
    int a,b,t,ans;
    bool f[maxn][2];
    inline int read()
    {
    	int x=0,f=1;char ch=getchar();
    	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
    	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    	return x*f;
    }
    int main()
    {
    	t=read();a=read();b=read();
    	f[0][0]=true;
    	F(j,0,1) F(i,0,t) if (f[i][j])
    	{
    		if (i+a<=t) f[i+a][j]=true;
    		if (i+b<=t) f[i+b][j]=true;
    		if (!j) f[i/2][1]=true;
    	}
    	ans=t;
    	while (!f[ans][0]&&!f[ans][1]) ans--;
    	printf("%d
    ",ans);
    }
    


  • 相关阅读:
    安卓9.0内测的背后,是上万App开发者半年来的适配优化
    错误记录:vue跟vue编译器版本不一致
    jspdf简单使用
    vue input添加回车触发
    vue watch bug记录
    SecureCRT通过拷贝配置文件登陆
    仿射变换
    opencv图像的旋转
    图像旋转的原理
    CvScalar
  • 原文地址:https://www.cnblogs.com/wgwyanfs/p/7060709.html
Copyright © 2011-2022 走看看