Type: Default 1000ms 256MiB

贫穷的Joey

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

Joey 很穷(;´д`)ゞ,因此他的朋友 Chandler 想要借给他一些钱(〃 ̄︶ ̄)人( ̄︶ ̄〃)。但是 Joey 的自尊心很强,为了不让他的自尊心受挫又能给他钱,Chandler 打算和他玩一个游戏。

在这个游戏中,Chandler 会给 Joey 一个数组 a1,a2,…,an(n≥2,ai∈Z+)a_1,a_2,\dots,a_n(n\ge 2,a_i \in \mathbb{Z^+})。Joey 可以对这个数组进行如下的操作任意次:

  1. 选择一对 i i 和 j j ( 1≤i<j≤n) 1 \le i < j \le n) .
  2. 选择两个整数 x x 和 y y ( x,y≥1 x, y \ge 1 ) 使得 x⋅y=ai⋅aj x \cdot y = a_i \cdot a_j .
  3. 将 ai,aja_i, a_j 分别替换为 x,yx, y.

最后, Joey 将得到的钱就是 aa 数组中所有值的和。即 Joey 所得的钱 =∑i=1nai= \sum^{n}_{i=1}a_{i} .

你需要求出一个整数 ansans,即 Joey 最多可以得到的钱,并输出 2022⋅ans2022 \cdot ans 。为什么要乘以 20222022 呢?因为我们再也见不到它了!(悲)

输入数据保证 aa 数组内所有数的乘积不超过 101210^{12},即 ∏i=1nai≤1012\prod^{n}_{i=1}a_{i} \le 10^{12}.

输入格式

输入包含多组测试数据。

  • 第一行,一个整数 TT,代表测试数据组数。
  • 对于每一组测试数据,第一行为一个整数 n(2≤n≤50)n(2 \leq n \leq 50),表示数组 aa 的长度。第二行为 nn 个整数 a1,a2,…,an(1≤ai≤106)a_1,a_2,\dots,a_n( 1 \leq a_i \leq 10^6 ),表示 aa 数组。保证 aa 数组内所有数的乘积不超过 101210^{12},即 ∏i=1nai≤1012\prod^{n}_{i=1}a_{i} \le 10^{12}.

输出格式

共一行,一个整数,表示 Joey 最多可以得到的钱乘以 2022 后的值。

输入输出样例 #1

输入 #1

3
3
2 3 2
2
1 3
3
1000000 1000000 1

输出 #1

28308
8088
2022000000004044

说明/提示

在测试样例的第一组测试数据中,Joey 可以这么做:

  • 他选择 i=1,j=2 i = 1 , j = 2 (可得 a[i]⋅a[j]=6 a[i] \cdot a[j] = 6 ), 使 x=6,y=1 x = 6, y = 1 ,然后改变原数组使 a[i]=x=6,a[j]=y=1 a[i] = x = 6 , a[j] = y = 1 . 即原数组发生如下变化:
$$[2, 3, 2] \xrightarrow[x = 6,\; y = 1]{i = 1,\; j = 2} [6, 1, 2]$$
  • 他选择 i=1,j=3i = 1 , j = 3 (可得 a[i]⋅a[j]=12 a[i] \cdot a[j] = 12 ), 使 x=12,y=1 x = 12 , y = 1 然后改变原数组使 a[i]=x=12,a[j]=y=1 a[i] = x = 12 , a[j] = y = 1 . 即原数组发生如下变化:
$$[6, 1, 2] \xrightarrow[x = 12,; y = 1]{i = 1,\; j = 3} [12, 1, 1]$$

综上所述, Joey 可以得到的最多的钱即为 12+1+1=1412+1+1=14 元,所以输出应为 14×2022=2830814\times 2022 = 28308.

校赛新手热身(二)

Not Attended
Status
Done
Rule
XCPC
Problem
7
Start at
2026-11-9 22:30
End at
2026-11-16 4:30
Duration
150 hour(s)
Host
Partic.
90