这个人说的非常非常非常清晰,强烈推荐https://www.youtube.com/watch?v=uSFzHCZ4E-8
对数组进行切分, 根据二进制排出父子节点。
class BIT {
int[] aux;
public BIT(int[] nums) {
aux = new int[nums.length + 1];
System.arraycopy(nums, 0, aux, 1, nums.length);
for (int i = 1; i < aux.length; i++) {
int index = i + lowBit(i);
if (index < aux.length) {
aux[index] += aux[i];
}
<