#C9239. Pirate Coin Distribution
Pirate Coin Distribution
Pirate Coin Distribution
You are given n pirates and m coins. The coins are distributed among the pirates sequentially using the following rule:
Each pirate takes \(\lfloor \frac{m_{current}}{2} \rfloor\) coins, where \(m_{current}\) is the number of coins remaining before his turn. After a pirate takes his share, the coins left are reduced accordingly.
Your task is to compute the number of coins each pirate receives.
Note: The division is performed using floor (integer) division.
Example: If there are 3 pirates and 8 coins, the distribution is as follows:
- Pirate 1 takes \(\lfloor 8/2 \rfloor = 4\) coins (remaining coins = 4).
- Pirate 2 takes \(\lfloor 4/2 \rfloor = 2\) coins (remaining coins = 2).
- Pirate 3 takes \(\lfloor 2/2 \rfloor = 1\) coin (remaining coins = 1).
The final distribution is 4 2 1
.
inputFormat
The input consists of a single line containing two space-separated integers:
n
\( (1 \le n \le 10^5)\) — the number of pirates.m
\( (0 \le m \le 10^{18})\) — the initial number of coins.
outputFormat
Output a single line containing n
integers separated by a single space. The i-th integer represents the number of coins received by the i-th pirate.
3 8
4 2 1
</p>