# 0319. Bulb Switcher ###### tags: `Leetcode` `Medium` Link: https://leetcode.com/problems/bulb-switcher/ ## 思路 找规律 根据每个数的因数个数来判断是否需要关闭/打开 **完全平方数的因数个数是奇数,非完全平方数因数个数为偶数。** ## Code ```java= class Solution { public int bulbSwitch(int n) { int count = 0; for(int i = 1;i*i<=n;i++){ count++; } return count; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up