题意:给定一个数组你个数的数组a,定义sum(i, j)表示sigma(a[i],...a[j]),以及另外一个函数f(i, j) = (i - j)^2 + sum(i+1, j)^2 求最小的f(i, j)(i < j) 思路:变形一下f(i, j) = (i - j)^2 + (sum[j] - sum[i])^2 那么把i看成x,sum[i]看成y,那就等价于求二维平面的最近点对吗. 二维平面求最近点对有一个经典nlognlogn的分治算法.. code: #include <bits…