int clockPath(int n) { if (n & 1) return 0; int dp[12] = {0}; dp[0] = 1; for (int i = 1; i <= n; i ++ ) { if (i & 1) { for (int j = 1; j < 12; j += 2 ) dp[j] = dp[j-1] + dp[(j==11?0:j+1)]; } else { for (int j = 0; j < 12; j += 2 ) dp[j] = dp[(j==0?11:j-1)] + dp[j+1]; } } return dp[0]; }这个是改进后的动态规划算法,空间复杂度降为O(1),需要稍微想一下,其实就是利用奇偶性错位更新