#K12166. Nut Distribution Among Storage Sites
Nut Distribution Among Storage Sites
Nut Distribution Among Storage Sites
You are given two integers \(n\) and \(m\). Your task is to distribute \(n\) nuts among \(m\) storage sites as evenly as possible. Each storage site initially receives \(\lfloor\frac{n}{m}\rfloor\) nuts. Additionally, the first \(n \bmod m\) storage sites receive one extra nut. After the distribution, you need to output two lines:
- The first line contains \(m\) integers which represent the number of nuts in each storage site.
- The second line lists the 1-indexed positions of the storage sites that received the maximum number of nuts.
For example, if \(n = 10\) and \(m = 3\), the distribution is [4, 3, 3]
and the storage site with the maximum nuts is the first one.
inputFormat
The input consists of a single line containing two space-separated integers \(n\) and \(m\) where \(1 \leq n, m \leq 10^6\).
outputFormat
Output two lines:
- The first line contains \(m\) space-separated integers representing the number of nuts at each storage site.
- The second line contains the space-separated 1-indexed positions of all storage sites that have the maximum number of nuts.
10 3
4 3 3
1
</p>