3 ms·
The Competitive Programmer's Handbook by Antti Laaksonen (pllk) [0] presents an alternative formulation which seems fairly intuitive to derive. The idea is to t
by karlding 6y ago
The Competitive Programmer's Handbook by Antti Laaksonen (pllk) [0] presents an alternative formulation which seems fairly intuitive to derive. The idea is to take a "normal" for-loop iterating through the entire array (a constant step size of 1), and instead use a large initial step size (n/2) which halves at each iteration.
[0] https://cses.fi/book/index.php https://cses.fi/book/index.php