No.2146 2 Pows
タグ : / 解いたユーザー数 35
作問者 :
milkcoffee
/ テスター :
👑
hamamu
nok0
Problem Statement
Consider a non-empty multiset $S$ in which every element is a power of $2$.
A power of $2$ is an integer that can be expressed as $2^i$ using a non-negative integer $i$.
Here, let $x$ be the number of elements contained in $S$, $y$ be the number of distinct values of the elements, and $2^z$ be the maximum value of the elements, and define the cost of $S$ as $Ax+By+Cz$.
For example, if $S= \{ 1, 1, 2, 8 \}$, then $x=4, y=3, z=3$.
For each non-negative integer $k$ $(0 \leq k \leq N-1)$ less than $N$, answer the following question.
- Consider an $S$ such that the sum of the elements of $S$ leaves a remainder of $k$ when divided by $N$. Find the minimum cost of $S$.
Input
$N$ $A$ $B$ $C$
- $2 \leq N \leq 2 \times 10^5$
- $1 \leq A,B,C \leq 10^9$
- All inputs are integers.
Output
Output $N$ lines.
On the $i$-th line, output the answer for $k=i-1$ as an integer.
Sample
Sample 1
Input
3 5 2 1
Output
15 7 8
For $k=0$:
When $S= \{1,2 \}$, we have $x=2,y=2,z=1$, and the cost is $5 \times 2+2 \times 2 + 1 \times 1=15$, which is the minimum.
For $k=1$:
When $S= \{1 \}$, we have $x=1,y=1,z=0$, and the cost is $5 \times 1+2 \times 1 + 1 \times 0=7$, which is the minimum.
For $k=2$:
When $S= \{2 \}$, we have $x=1,y=1,z=1$, and the cost is $5 \times 1+2 \times 1 + 1 \times 1=8$, which is the minimum.
Sample 2
Input
13 25 35 5
Output
150 60 65 80 70 105 85 115 75 100 110 95 90
For example, in the case of $k=3$, the cost is minimized when $S= \{ 16 \}$.
In this case, $x=1,y=1,z=4$, and the cost is $80$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。