luogu#P4817. [USACO15DEC] Fruit Feast G

[USACO15DEC] Fruit Feast G

题目描述

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,000)(1 ≤ 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!

输入格式

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

输出格式

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

题目大意

题目描述

Bessie 再次闯入了 Farmer John 的房屋!她在厨房发现了一堆柠檬和一堆橙子(每种水果的数量都可以视为无限),并决定尽可能多吃。

Bessie 的最大饱腹度为 TT1T5,000,0001 \leq T \leq 5,000,000)。每吃一个橙子会使饱腹度增加 AA,每吃一个柠檬会使饱腹度增加 BB1A,BT1 \leq A,B \leq T)。此外,Bessie 最多可以喝一次水,这将使饱腹度立即减半(向下取整)。

请帮助 Bessie 计算她能达到的最大饱腹度!

输入格式

唯一一行包含三个整数 TTAABB

输出格式

输出一个整数,表示 Bessie 能达到的最大饱腹度。

说明/提示

题目提供者:Nathan Pinsker

8 5 6
8

提示

Problem credits: Nathan Pinsker