1. 常用算法代码实现 - 图2的实现

  1. int ans = 0, temp = m;
  2. for (int i = 0; i < n - 1; i++) {
  3. temp *= m - i;
  4. ans += temp;
  5. }

2.