以1/2为公比的等比数列求和(无穷级数),经过的距离包括往上弹的,所以乘3:

import java.util.*;

public class Balls {
    public int calcDistance(int A, int B, int C, int D) {
        // write code here
        return (A + B + C + D)*3;
    }
}