SOURCE

function makeChagne( change ) {
    let result = []
    for(let i = 0; i <= change; i++) {
        result.push(new Array(5).fill(0))
    }
    let nums = new Array(change + 1).fill(Math.pow(10, 5))
    nums[0] = 0, nums[1] = 1
    let money = [100, 50, 20, 5, 1]
    for(let i = 0; i <= change; i++) {
        for(let j = i; j >= 0; j--) {
            if(i - money[j] < 0) break
            let x = nums[i - money[j]] + 1
            let y = nums[i]
            if(x < y) {
                nums[i] = x;
                result[i] = result[i - money[j]].slice()
                result[i][j] += 1
            }
        }   
    }
    return result[change]
}
console.log(makeChagne(100))
console 命令行工具 X clear

                    
>
console