public int[] solution(int n, int s) {
if (n > s) {
return new int[] { -1 };
}
int[] answer = new int[n];
int quotient = s / n;
int remainder = s % n;
if (remainder == 0) {
for (int i = 0; i < n; i++) {
answer[i] = quotient;
}
return answer;
}
for (int i = 0; i < n; i++) {
answer[i] = quotient + (i < n - remainder ? 0 : 1);
}
return answer;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/12938