1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-12 17:05:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/Alice 和 Bob 玩鲜花游戏 [alice-and-bob-playing-flower-game].html
2025-09-29 14:43:44 +08:00

48 lines
1.6 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>Alice 和 Bob 在一片田野上玩一个回合制游戏他们之间有两排花。Alice 和 Bob 之间第一排有 <code>x</code> 朵花,第二排有 <code>y</code> 朵花。</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2025/08/27/3021.png" style="width: 300px; height: 150px;" /></p>
<p>游戏过程如下:</p>
<ol>
<li>Alice 先行动。</li>
<li>每一次行动中,当前玩家必须选择其中一排,然后在这边摘一朵鲜花。</li>
<li>一次行动结束后,如果两排上都没有剩下鲜花,那么 <strong>当前</strong>&nbsp;玩家抓住对手并赢得游戏的胜利。</li>
</ol>
<p>给你两个整数&nbsp;<code>n</code>&nbsp;&nbsp;<code>m</code>&nbsp;,你的任务是求出满足以下条件的所有&nbsp;<code>(x, y)</code>&nbsp;对:</p>
<ul>
<li>按照上述规则Alice 必须赢得游戏。</li>
<li>第一排的鲜花数目&nbsp;<code>x</code>&nbsp;必须在区间&nbsp;<code>[1,n]</code>&nbsp;之间。</li>
<li>第二排的鲜花数目 <code>y</code>&nbsp;必须在区间&nbsp;<code>[1,m]</code>&nbsp;之间。</li>
</ul>
<p>请你返回满足题目描述的数对&nbsp;<code>(x, y)</code>&nbsp;的数目。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<b>输入:</b>n = 3, m = 2
<b>输出:</b>3
<b>解释:</b>以下数对满足题目要求:(1,2) (3,2) (2,1) 。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<b>输入:</b>n = 1, m = 1
<b>输出:</b>0
<b>解释:</b>没有数对满足题目要求。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n, m &lt;= 10<sup>5</sup></code></li>
</ul>