#K57027. Minimize Sum of Squares
Minimize Sum of Squares
Minimize Sum of Squares
Given two positive integers \(S\) and \(K\), your task is to construct \(K\) integers \(a_1, a_2, \dots, a_K\) such that they satisfy the equation \(a_1 + a_2 + \cdots + a_K = S\) and the sum of squares \(\sum_{i=1}^{K} a_i^2\) is minimized. The optimal strategy is to make the numbers as equal as possible.
For example, if \(S = 20\) and \(K = 3\), the optimal solution is 6, 7, 7 since \(6+7+7=20\) and this arrangement minimizes \(6^2+7^2+7^2\).
inputFormat
The input consists of a single line containing two integers \(S\) and \(K\) separated by a space.
outputFormat
Output a single line with \(K\) integers separated by spaces, in non-decreasing order, representing the solution.
## sample20 3
6 7 7