1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/换水问题 [water-bottles].html
2023-12-09 18:53:53 +08:00

41 lines
1.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>超市正在促销,你可以用 <code>numExchange</code> 个空水瓶从超市兑换一瓶水。最开始,你一共购入了 <code>numBottles</code> 瓶水。</p>
<p>如果喝掉了水瓶中的水,那么水瓶就会变成空的。</p>
<p>给你两个整数 <code>numBottles</code><code>numExchange</code> ,返回你 <strong>最多</strong> 可以喝到多少瓶水。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/07/19/sample_1_1875.png" style="height: 240px; width: 480px;" /></strong></p>
<pre>
<strong>输入:</strong>numBottles = 9, numExchange = 3
<strong>输出:</strong>13
<strong>解释:</strong>你可以用 <code>3</code> 个空瓶兑换 1 瓶水。
所以最多能喝到 9 + 3 + 1 = 13 瓶水。
</pre>
<p><strong>示例 2</strong></p>
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/07/19/sample_2_1875.png" style="height: 240px; width: 790px;" /></p>
<pre>
<strong>输入:</strong>numBottles = 15, numExchange = 4
<strong>输出:</strong>19
<strong>解释:</strong>你可以用 <code>4</code> 个空瓶兑换 1 瓶水。
所以最多能喝到 15 + 3 + 1 = 19 瓶水。
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= numBottles &lt;= 100</code></li>
<li><code>2 &lt;= numExchange &lt;= 100</code></li>
</ul>