functionsolution(n, s) {constquotient=Math.floor(s / n);constmod= s % n;var answer =newArray(n).fill(quotient);if (s < n) return [-1];returnanswer.map((e,i)=>answer.length- i <= mod ? e +1: e);}
풀이
각 원소의 합이 S가 되는 수의 집합에서 각 원소의 곱이 최대가 되려면 각 원소들은 총 합인 S는 가능한한 비슷한 크기로 나뉘어진 값을 가져야함