Universal Cup Judging System

Universal Cup

시간 제한: 7.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

$n$ 個の正整数からなる配列 $a$ が与えられます。

その要素を任意の順序に並べ替えます。得られた配列が $b_1, b_2, \ldots, b_n$ であるとき、その値は

$$\operatorname{lcm}(b_1, b_2) + \operatorname{lcm}(b_2, b_3) + \ldots + \operatorname{lcm}(b_{n-1}, b_n),$$

すなわち、隣り合う要素のすべての組の最小公倍数の総和です。

$a$ のすべての並べ替えにわたる、この値の最大値を求めてください。

入力

最初の行には、テストケースの数を表す整数 $t$ ($1 \le t \le 10$) が1つ与えられます。

各テストケースの最初の行には、配列の要素数を表す整数 $n$ ($1 \le n \le 100\,000$) が1つ与えられます。

2行目には、$n$ 個の整数 $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 7$) が与えられます。

すべてのテストケースにわたる $n$ の総和は $100\,000$ 以下であることが保証されます。

出力

各テストケースについて、可能な値の最大値を表す整数を1つ出力してください。

入出力例

入力 1

1
2
5 2

出力 1

10

入力 2

1
6
2 2 2 3 3 3

出力 2

30

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.