Leetcode-Question-319: Bulb Switcher

原文链接:
https://leetcode.com/problems/bulb-switcher/

题目描述:

Bulb Switcher
Difficulty: Medium

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 nth round, you only toggle the last bulb. Find how many bulbs are on after n rounds.

Example:

解答:

思路只有一个:只有完全平方数那些个灯泡会亮。

 

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注