1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/灯泡开关 Ⅱ [bulb-switcher-ii].html
2022-03-29 12:43:11 +08:00

34 lines
1.3 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>现有一个房间,墙上挂有&nbsp;<code>n</code>&nbsp;只已经打开的灯泡和 4 个按钮。在进行了&nbsp;<code>m</code>&nbsp;次未知操作后,你需要返回这&nbsp;<code>n</code>&nbsp;只灯泡可能有多少种不同的状态。</p>
<p>假设这 <code>n</code> 只灯泡被编号为 [1, 2, 3 ..., n],这 4 个按钮的功能如下:</p>
<ol>
<li>将所有灯泡的状态反转(即开变为关,关变为开)</li>
<li>将编号为偶数的灯泡的状态反转</li>
<li>将编号为奇数的灯泡的状态反转</li>
<li>将编号为 <code>3k+1</code> 的灯泡的状态反转k = 0, 1, 2, ...)</li>
</ol>
<p><strong>示例 1:</strong></p>
<pre><strong>输入:</strong> n = 1, m = 1.
<strong>输出:</strong> 2
<strong>说明:</strong> 状态为: [开], [关]
</pre>
<p><strong>示例 2:</strong></p>
<pre><strong>输入:</strong> n = 2, m = 1.
<strong>输出:</strong> 3
<strong>说明:</strong> 状态为: [开, 关], [关, 开], [关, 关]
</pre>
<p><strong>示例 3:</strong></p>
<pre><strong>输入:</strong> n = 3, m = 1.
<strong>输出:</strong> 4
<strong>说明:</strong> 状态为: [关, 开, 关], [开, 关, 开], [关, 关, 关], [关, 开, 开].
</pre>
<p><strong>注意:</strong>&nbsp;<code>n</code>&nbsp;&nbsp;<code>m</code> 都属于 [0, 1000].</p>