luogu#P10426. [蓝桥杯 2024 省 B] 宝石组合

[蓝桥杯 2024 省 B] 宝石组合

Problem Description

In a mysterious forest, there lives a little elf named Xiao Lan. One day, he accidentally discovered a treasure hidden in a tree hole, filled with gems that sparkle with beautiful light. These gems have different colors and shapes, but the most eye-catching part is their unique “shininess” attribute. Each gem is born with a special ability to emit flashes of different intensities. Xiao Lan found a total of nn gems. The “shininess” attribute value of the ii-th gem is HiH_i. Xiao Lan will choose three gems from these nn gems to form a combination. The beauty level SS after combining can be measured by the following formula:

$$S = H_a H_b H_c \cdot \frac{\operatorname{LCM}(H_a, H_b, H_c)}{\operatorname{LCM}(H_a, H_b) \cdot\operatorname{LCM}(H_a, H_c) \operatorname{LCM}(H_b, H_c)}$$

Here, LCM\operatorname{LCM} denotes the least common multiple function.

Xiao Lan wants the beauty level SS of the three-gem combination to be as high as possible. Please help him find the plan with the maximum beauty level. If there are multiple plans with the same SS, choose the one that is lexicographically smallest after sorting the three HH values in ascending order first.

Input Format

The first line contains an integer nn, representing the number of gems.
The second line contains nn integers H1,H2,HnH_1, H_2, \dots H_n, representing the shininess of each gem.

Output Format

Output one line containing three integers, representing the “shininess” of the three gems that satisfy the conditions.

5
1 2 3 4 9

1 2 3

Hint

Constraints

  • For 30%30\% of the data, n100n \leq 100, Hi103H_i \leq 10^3.
  • For 60%60\% of the data, n2×103n \leq 2 \times 10^3.
  • For all testdata, it is guaranteed that 3n1053 \leq n \leq 10^5, 1Hi1051 \leq H_i \leq 10^5.

Translated by ChatGPT 5