There is a room with n lights which are turned on initially and 4 buttons on the wall. After performing exactly m unknown operations towards buttons, you need to return how many different kinds of status of the n lights could be.

Suppose n lights are labeled as number [1, 2, 3 ..., n], function of these 4 buttons are given below:

  1. Flip all the lights.
  2. Flip lights with even numbers.
  3. Flip lights with odd numbers.
  4. Flip lights with (3k + 1) numbers, k = 0, 1, 2, ...

Example 1:

Input: n = 1, m = 1.
Output: 2
Explanation: Status can be: [on], [off]

Example 2:

Input: n = 2, m = 1.
Output: 3
Explanation: Status can be: [on, off], [off, on], [off, off]

Example 3:

Input: n = 3, m = 1.
Output: 4
Explanation: Status can be: [off, on, off], [on, off, on], [off, off, off], [off, on, on].

Note: n and m both fit in range [0, 1000].

Runtime: 4 ms, faster than 29.00% of C++ online submissions for Bulb Switcher II.

找规律题。

class Solution {
public:
int flipLights(int n, int m) {
if(m == ) return ;
if(n == ) return ;
if(n == && m == ) return ;
if(n == ) return ;
if(m==) return ;
if(m == ) return ;
return ;
}
};

LC 672. Bulb Switcher II的更多相关文章

  1. 【LeetCode】672. Bulb Switcher II 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  2. [LeetCode] Bulb Switcher II 灯泡开关之二

    There is a room with n lights which are turned on initially and 4 buttons on the wall. After perform ...

  3. [Swift]LeetCode672. 灯泡开关 Ⅱ | Bulb Switcher II

    There is a room with n lights which are turned on initially and 4 buttons on the wall. After perform ...

  4. [LeetCode] Bulb Switcher 灯泡开关

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

  5. LeetCode 319 ——Bulb Switcher——————【数学技巧】

    319. Bulb Switcher My Submissions QuestionEditorial Solution Total Accepted: 15915 Total Submissions ...

  6. 【LeetCode】319. Bulb Switcher 解题报告(Python)

    [LeetCode]319. Bulb Switcher 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/bulb ...

  7. LeetCode Bulb Switcher 319

    变换灯泡颜色 There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off ...

  8. Leetcode Bulb Switcher

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

  9. Bulb Switcher

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

随机推荐

  1. fastadmin 金额 字段类型及html验证

    金额 字段类型  整数  小数 decimal    10      2 float          10     2 html验证 <div class="form-group&q ...

  2. shell脚本中的EOF以及文件重定向

    <<EOF  (内容)  EOF  可以把EOF替换成其他东西(分解符)  意思是把内容当作标准输入传给程序 这里再简要回顾一下<<的用法.当Shell看到<<的时 ...

  3. 前端获取http和完整项目名

    <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...

  4. 给移动硬盘装win10,知道这些就足够了

    随着制造工业的不断发展,储存介质逐渐廉价化,以某猫和某狗为代表的电商平台上都能轻松买到大容量的原装移动硬盘.如果工厂的产品还不能满足你的要求,那么DIY是一个不错的选择,可以选择购买移动硬盘盒(2.5 ...

  5. Jmeter (一) 安装

    https://blog.csdn.net/ls1792304830/article/details/52718177 一.准备工具 1.Windows 操作系统 2.jmeter 3.JDk 依赖环 ...

  6. Hive压缩和存储(十二)

    压缩和存储 1. Hadoop压缩配置 1) MR支持的压缩编码 压缩格式 工具 算法 文件扩展名 是否可切分 DEFAULT 无 DEFAULT .deflate 否 Gzip gzip DEFAU ...

  7. 两步创建vue全局组件

    import Login from './Login' export default { install: function(Vue){ Vue.component('Login', Login); ...

  8. 合并K个sorted list

    合并k个已经排好序的数列是面试中也比较容易被问到的一个算法,有很多种解决,其中第一时间比较容易想到的解法如下: 对于这三组从小到大的数列: 如此循环,最终就将三个已经排序的数列的数字按从小到大的顺序排 ...

  9. solr 倒排索引(转载)

    原文地址:http://blog.csdn.net/chichengit/article/details/9235157 http://blog.csdn.net/njpjsoftdev/articl ...

  10. java.io.WinNTFileSystem

    Unicode-aware FileSystem for Windows NT/2000. Since: 1.4 Author: Konstantin Kladko