注意到:
(0, 0) => 0
(-1, 0) => 1
(0, 1) => 1 + 2
(1, 0) => 1 + 2 + 2
(0, -1) => 1 + 2 + 2 + 2
(-2, 0) => 1 + 4 * 2 + 1
因此,坐标轴上的点有
(-n, 0) => 1 + sum( 4 * 2 * i + 1), i = 1, 2 ..., n - 1
(0, n) => d(-n, 0) + 2 * n
(n, 0) => d(-n, 0) + 2 * 2 * n
(0, -n) => d(-n, 0) + 3 * 2 * n
对于第四象限点(13, -15),因为在y=-x直线下方,所以
d(13, -15) = d(15, -15) + 2
= d(15, 0) + 15 + 2
= d(-15, 0) + 2 * 2 * 15 + 15 + 2
= 1 + sum(4 * 2 * i + 1) + 77
= 855 + 77 = 932
没验算,随便写的,写错了别打我(x
想了下,把两步看成一起作为一个L型会容易点