Skip to content

Commit 1b0b519

Browse files
authored
Update building-boxes.py
1 parent 15e0b6c commit 1b0b519

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Python/building-boxes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ def minimumBoxes(self, n):
1717
# (h-1)*h*(h+1) < h^3 <= 6n < h*(h+1)*(h+2) < (h+1)^3
1818
h -= 1
1919
n -= h*(h+1)*(h+2)//6
20-
d = int(math.ceil((-1+math.sqrt(1+8*n))/2)) # find min d s.t. d*(d+1)//2 >= n
20+
d = int(math.ceil((-1+(1+8*n)**0.5)/2)) # find min d s.t. d*(d+1)//2 >= n
2121
return h*(h+1)//2 + d

0 commit comments

Comments
 (0)