Kth Switch Toggle
Programming Interview
Hard
4 views
Problem Description
You have n bulbs all OFF. For i from 1 to n, toggle every i-th bulb. At the end, how many bulbs are ON? Output count.
Input Format
One integer n.
Output Format
One integer count.
Official Solution
import sys,math
s=sys.stdin.read().strip()
if not s: sys.exit(0)
n=int(s)
sys.stdout.write(str(int(math.isqrt(n))))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!