No.2233 Average
Problem Statement
You are given non-negative integers $a, b, c$. Perform the following operation on these $3$ numbers $K$ times.
- Simultaneously replace $a, b, c$ with $\lfloor \frac{b + c}{2} \rfloor, \lfloor \frac{c + a}{2} \rfloor, \lfloor \frac{a + b}{2} \rfloor$, respectively.
Find the value of $a + b + c$ after performing the operation $K$ times.
For each input, solve $T$ test cases per $1$ input file.
Input
$T$
$\mathrm{case}_1$
$\vdots$
$\mathrm{case}_T$
Each test case is given in the following format.
$a$ $b$ $c$ $K$
- All input values are integers.
- $1\leq T\leq 10^5$
- $0\leq a, b, c, K \leq 10^{18}$
Output
Print $T$ lines. On the $i$-th line ($1\leq i\leq T$), print the answer to $\mathrm{case}_i$.
Sample
Sample 1
Input
3 10 6 3 2 0 1 1 10 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
Output
18 0 3000000000000000000
In the $1$-st test case, the $1$-st operation gives $a = 4, b = 6, c = 8$, and the $2$-nd operation gives $a = 7, b = 6, c = 5$. Therefore, print $7 + 6 + 5 = 18$.
In the $2$-nd test case, performing the operation $2$ times gives $a = b = c = 0$, and no further operation changes these values.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
だれ
ぷら