# Problem 319: Bulb Switcher

> <https://leetcode.com/problems/bulb-switcher/#/description>

## 思路

> <https://discuss.leetcode.com/topic/39558/share-my-o-1-solution-with-explanation>

这道题就是脑筋急转弯。

* 简单讲，就是找小于 n 的完全平方数的个数（因为他们的 factor 的个数是奇数）
* 而这样又直接等于 n 开方

```java
public class Solution {
    public int bulbSwitch(int n) {
        return (int) Math.sqrt(n);
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liuyang89116.gitbook.io/my-leetcode-book/post_chapter_2_math/problem-319-bulb-switcher.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
