問題一覧 > 通常問題

No.2233 Average

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 166
作問者 : だれ / テスター : ぷら
お気に入りにしたユーザー ProblemId : 9153 / 自分の提出
問題文最終更新日: 2025-10-14 00:39:22
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 379 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。