No.1738 What's in the box?
タグ : / 解いたユーザー数 186
作問者 :
nok0
とりゐ
Problem Statement
There are $N$ boxes. The boxes are numbered $1, 2, 3, ... N $. Each box contains $0$ or more balls.
In addition, the following facts are known.
- The weight of $1$ ball is a positive real number, and all balls have the same weight.
- The total weight of the balls in box $i$ is $W_i$.
- The total number of balls in the $N$ boxes is $M$.
From these conditions, find the number of balls in each box.
Constraints
- All inputs are integers.
- $1 \leq N \leq 1000$
- $0 \leq M \leq 10^{9}$
- $0 \leq W_i \leq 10^{9}$ ($1 \leq i \leq N$)
- The input is given such that a combination of numbers of balls satisfying the conditions exists uniquely.
Input
The input is given from standard input in the following format.
$N$ $M$ $W_1$ $W_2$ $W_3$ $\dots$ $W_N$
・The $1$st line contains $N$ and $M$, separated by a space.
・The $2$nd line contains $W_i$ ($1 \leq i \leq N$), separated by spaces.
Output
$A_1$ $A_2$ $\dots$ $A_N$
Output the sequence $A$, which represents the combination of numbers of balls satisfying the given conditions, separated by spaces.
Here, $A_i$ is the number of balls in the $i$-th box.
Print a newline at the end.Sample
Sample 1
Input
3 30 1 2 3
Output
5 10 15
If the weight of $1$ ball is $0.2$ and the boxes contain $5$, $10$, and $15$ balls in order starting from box $1$, all the given conditions are satisfied.
Note that the weight of $1$ ball is not necessarily an integer.
Sample 2
Input
3 100 100 0 0
Output
100 0 0
Box $1$ contains $100$ balls of weight $1$. Note that some boxes may contain no balls.
Sample 3
Input
5 3267948 399576 2653028 2603840 54518 824934
Output
199788 1326514 1301920 27259 412467
The weight of $1$ ball is $2$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。