RishBlogs

Iterating over Floors

830C-Bamboo Partition
It turns out the possible values of \(answer\) is of the type \(\lfloor\frac{x}{y}\rfloor\), and we need some way to iterate through these values which are \(O(\sqrt{n})\). This can be done with some neat trick.

1
2
3
4
for(LL i = 1; i <= K; i++){
	LL possible = (K/i);
	i = K/possible; 
}