Need help with a math problem

Revision en1, by Neev4321, 2024-11-09 16:36:20

I recently came across this blog post and decided to try some of its problems. I am stuck on this problem. I can think of a naive O(n^2) solution by iterating through all pairs but do not see any redundancy in this solution. I cannot see a way to make it sub-quadratic (other than using the fact that 1 ≤ ai ≤ 2.5 * 10^6, maybe?). Any hints would be appreciated.

Tags i need help, math

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Neev4321 2024-11-09 16:37:43 43
en1 English Neev4321 2024-11-09 16:36:20 481 Initial revision (published)