LoginSignup
0
0

More than 5 years have passed since last update.

現在のインデックスから、最遠のインデックスを求める方法。さらに最短方向を求める。

Last updated at Posted at 2015-03-23

・最遠の判定
総数が偶数の場合、最遠は1つだけ存在する。
abs(cur - max) == max / 2 //max >= 0

総数が奇数の場合、最遠は2つ存在する
(max / 2) - (cur - max) = x
x < 1 && x > -1

・差による判定から・・・どうするか、
 中心より下か上かにより
  a >= max/2
(a = abs(cur − max))

■絶対値にする必要はないのだろうか?

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0