(记录)剑指offer编程题解法汇总-跳台阶

这个解法有问题,之前自己怎么想的都忘了。

先记录下,后面慢慢回忆一下当初怎么想的这个思路

 

 /**
     * 跳台阶
     * @param target
     * @return
     */
    public static int JumpFloor(int target) {
        int count = 0;
        int max = target;
        if (target % 2 != 0) {
            max++;
        }
        for (int b = 0; b <= (max / 2); b++) {
            int a = target - 2 * b;
            if (b == 0) {
                count += 1;
                continue;
            }
            if (a == 0) {
                count += 1;
                continue;
            }
            double pow = Math.pow(1 + a, b);
            count += pow;
        }
        return count;
    }

你可能感兴趣的:(剑指Offer编程题,剑指offer编程题解法汇总)