首页 写随笔

cdcq(本博客废弃!现用博客:https://www.cnblogs.com/cdcq/)

本博客废弃!现用博客:https://www.cnblogs.com/cdcq/

导航

USACO 2015 December Contest, Gold Problem 2. Fruit Feast

Problem 2. 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 TT (1T5,000,0001≤T≤5,000,000). Eating an orange increases her fullness by AA, and eating a lemon increases her fullness by BB (1A,BT1≤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!

INPUT FORMAT (file feast.in):

The first (and only) line has three integers TT, AA, and BB.

OUTPUT FORMAT (file feast.out):

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

SAMPLE INPUT:

8 5 6

SAMPLE OUTPUT:

8

大概翻译一下:based有一个最大的丰满值t,初始丰满值是0,吃橘子加a丰满值,吃柠檬加b丰满值,还可以最多喝一次水来让丰满值减半(向下取整),求最后能达到的最大丰满值

递推智商题,用一个bool数组a[i]表示i能够取到

先一次循环i从0到t,如果i能取到(初始只有0能取到),i+a,i+b和i/2也能取到,这里因为i/2小于i而i是递增枚举,所以不担心会有两次喝水的情况

然后再一次循环i从0到t,这一次要处理第一次循环的时候新增的能取到的点(就是第一次循环时i/2原来不能取到但是i能取到然后i/2就能取到了),如果i能取到,i+a和i+b也能取到,不过这次不能喝水了

然后从t往下枚举看哪个小于t的最大的点能取到即可

最开始的时候我两次循环都是从0枚举到n+1,没想到再吃的过程中也不能超过t的限制,但这样居然还过了9组,usaco数据好水。。。

(round down是向下取整然后百度给我翻译成四舍五入mdzz

代码很简单,就不给了(其实是丢了

 

posted on 2016-12-11 10:18  cdcq_old  阅读(292)  评论(2编辑  收藏  举报