let num =65let type =4let money =[50,30,20,5]functionchange(num,type,money){let res =[]
res[0]=0for(let i=1;i<=num;i++){let arr =[]for(let j=0;j<money.length;j++){if(i>=money[j]){
arr.push(res[i-money[j]]+1)}}
res[i]= Math.min(...arr)}return res[num]===Infinity?'impossible': res[num]}
console.log(change(num,type,money))
let energy =newArray(2).fill(0).map(()=>(newArray(2).fill(0).map(()=>(newArray(2).fill(0)))))let used =newArray(2).fill(0).map(()=>(newArray(2).fill(0).map(()=>(newArray(2).fill(false)))))let s =[7,2,4,3,6,1,5,0]let a =12let count =0for(let i=0;i<2;i++){for(let j=0;j<2;j++){for(let k=0;k<2;k++){
energy[i][j][k]= s[count++]}}}let x=0,y=0,z=0;let res =0functiondfs(x,y,z,total,pre){if(x<0|| x>=2|| y<0|| y>=2|| z<0|| z>=2|| used[x][y][z]|| pre<=energy[x][y][z]){return}let now = energy[x][y][z]
total += now
used[x][y][z]=truedfs(x-1,y,z,total,now)dfs(x+1,y,z,total,now)dfs(x,y-1,z,total,now)dfs(x,y+1,z,total,now)dfs(x,y,z-1,total,now)dfs(x,y,z+1,total,now)
used[x][y][z]=false
res = Math.max(res,total)}dfs(x,y,z,0,Infinity)
console.log(res)