#K38722. Minimizing Square Sum

    ID: 26262 Type: Default 1000ms 256MiB

Minimizing Square Sum

Minimizing Square Sum

Given two positive integers \(N\) and \(K\), find a sequence of \(N\) positive integers \(a_1, a_2, \ldots, a_N\) such that:

  • \(a_1 + a_2 + \cdots + a_N = K\)
  • The sum of squares \(a_1^2 + a_2^2 + \cdots + a_N^2\) is minimized.

This is achieved when the numbers are as equal as possible. In other words, each number should either be \(\lfloor \frac{K}{N} \rfloor\) or \(\lfloor \frac{K}{N} \rfloor + 1\). The answer must be output in non-decreasing order.

inputFormat

The input consists of a single line with two space-separated integers \(N\) and \(K\), where \(N\) is the number of integers and \(K\) is the total sum.

You may assume that \(K\) is at least \(N\) so that a valid sequence exists.

outputFormat

Output \(N\) space-separated integers in non-decreasing order that represent the optimal sequence.

## sample
3 6
2 2 2