编辑代码

// 设置标准输入接口
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void (async function () {
  const amount = Number(await readline());
  const prices = JSON.parse(await readline());
  const ans = [];
  const backTrack = (path, val, sum) => {
    if (sum == val) {
      ans.push(path);
      return;
    }
    for (const price of prices) {
      if (sum + price > val) break;
      backTrack([...path, price], val, sum + price);
      //   path.pop();
    }
  };
  backTrack([], amount, 0);
  console.log(ans);
})();