题目解析
简单的可重复元素组合求解。
2023.08.01
更新了JS代码的输出格式逻辑,即在逗号后面加空格
JavaScript算法源码
/* JavaScript Node ACM模式 控制台输入获取 */
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const lines = [];
rl.on("line", (line) => {
lines.push(line);
if (lines.length === 2) {
const amount = lines[0] - 0;
const prices = JSON.parse(lines[1]);
console.log(getResult(amount, prices));
lines.length = 0;
}
});
function getResult(amount, prices) {
const res = [];
dfs(amount, prices, 0, 0, [], res);