leetcode:数学:Bulb Switcher(319)
来源:互联网 发布:excel数据预测方法 编辑:程序博客网 时间:2024/05/22 10:40
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off if it’s on). For the ith round, you toggle every i bulb. For the nth round, you only toggle the last bulb. Find how many bulbs are on after n rounds.
Example:
Given n = 3.
At first, the three bulbs are [off, off, off].
After first round, the three bulbs are [on, on, on].
After second round, the three bulbs are [on, off, on].
After third round, the three bulbs are [on, off, off].
So you should return 1, because there is only one bulb is on.
class Solution {public: int bulbSwitch(int n) { return (int)sqrt(n); }};
0 0
- leetcode:数学:Bulb Switcher(319)
- leetcode:数学:Bulb Switcher(319)
- LeetCode 319 Bulb Switcher(数学Tricks)
- leetcode 319 Bulb Switcher
- Leetcode-319 Bulb Switcher
- 【LEETCODE】319-Bulb Switcher
- LeetCode 319 Bulb Switcher
- leetcode 319 Bulb Switcher
- Leetcode 319 : Bulb Switcher
- LeetCode-319:Bulb Switcher
- LeetCode[319] Bulb Switcher
- leetcode 319 - Bulb Switcher
- LeetCode 319 Bulb Switcher
- LeetCode 319 -Bulb Switcher ( JAVA )
- LeetCode--No.319--Bulb Switcher
- LeetCode #319 - Bulb Switcher - Medium
- LeetCode:319. Bulb Switcher(C版本)
- LeetCode 319. Bulb Switcher(灯泡)
- 华为内部实施微服务架构
- javaweb项目开发,思想和细节一样重要
- 获取app文件大小 并对应响应单位:B KB MB GB; DecimalFormat
- [UnityShader]渲染队列、ZWrite和ZTest
- Java反射总结
- leetcode:数学:Bulb Switcher(319)
- PhpStorm 快捷键
- window平台安装 MongoDB
- python爬虫02 re模块与正则表达式
- easyui级联
- socket编程(2)—— 一对多通信
- YOLO VS2013 windows
- The operation couldn’t be completed. (LaunchServicesError error 0.)
- 跨站请求伪造CSRF防护方法