QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#12400. 石头游戏

統計

MianKing 有 $n$ 堆石头,每堆石头最多有 3 个。现在他想把所有石头合并成一堆。

为了达到目标,MianKing 每次可以选择两堆石头并将它们合并成一堆,新堆中的石头数量是这两堆石头数量之和。

由于搬运石头需要人力,在每次操作中,如果这两堆石头的数量分别为 $x$ 和 $y$,MianKing 需要支付 $(x \bmod 3)(y \bmod 3)$ 枚硬币。

现在 MianKing 想知道将所有石头合并成一堆所需支付的最少硬币数量。

输入格式

第一行包含 3 个整数 $a_1, a_2, a_3$,其中 $a_i$ 表示拥有 $i$ 个石头的堆数。

$0 \le a_i \le 10^9$ $\sum_{i=1}^3 a_i > 0$

输出格式

输出一个整数:MianKing 为达到目标所需支付的最少硬币数量。

样例

样例输入 1

1 1 1

样例输出 1

2

样例输入 2

99 66 55

样例输出 2

165

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.