309757: CF1731A. Joey Takes Money

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Joey Takes Money

题意翻译

- **题目翻译如下** ## 题目描述 Joey 很穷,因此他的朋友 Chandler 想要借给他一些钱。但是 Joey 的自尊心很强,为了不让他的自尊心受挫又能给他钱,Chandler 打算和他玩一个游戏。 在这个游戏中,Chandler 会给 Joey 一个数组 $a_1,a_2,\dots,a_n(n\ge 2,a_i \in \mathbb{N^+})$。Joey 可以对这个数组进行如下的操作任意次: 1. 选择一对 $ i $ 和 $ j $ ( $ 1 \le i < j \le n) $ . 2. 选择两个整数 $ x $ 和 $ y $ ( $ x, y \ge 1 $ ) 使得 $ x \cdot y = a_i \cdot a_j $ . 3. 将 $a_i, a_j$ 分别替换为 $x, y$. 最后, Joey 将得到的钱就是 $a$ 数组中所有值的和。即 Joey 所得的钱 $= \sum^{n}_{i=1}a_{i}$ . 你需要求出一个整数 $ans$,即 Joey 最多可以得到的钱,并输出 $2022 \cdot ans$ 。为什么要乘以 $2022$ 呢?因为我们再也见不到它了!(悲) 输入数据保证 $a$ 数组内所有数的乘积不超过 $10^{12}$,即 $\prod^{n}_{i=1}a_{i} \le 10^{12}$. ## 输入格式 输入包含多组测试数据。 - 第一行,一个整数 $T$,代表测试数据组数。 - 对于每一组测试数据,第一行为一个整数 $n(2 \leq n \leq 50)$,表示数组 $a$ 的长度。第二行为 $n$ 个整数 $a_1,a_2,\dots,a_n( 1 \leq a_i \leq 10^6 )$,表示 $a$ 数组。保证 $a$ 数组内所有数的乘积不超过 $10^{12}$,即 $\prod^{n}_{i=1}a_{i} \le 10^{12}$. ## 输出格式 共一行,一个整数,表示 Joey 最多可以得到的钱乘以 2022 后的值。 ## 提示 在测试样例的第一组测试数据中,Joey 可以这么做: - 他选择 $ i = 1 , j = 2 $ (可得 $ a[i] \cdot a[j] = 6 $ ), 使 $ x = 6, 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 = 3 $ (可得 $ a[i] \cdot a[j] = 12 $ ), 使 $ x = 12 , 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=14$ 元,所以输出应为 $14\times 2022 = 28308$.

题目描述

Joey is low on money. His friend Chandler wants to lend Joey some money, but can't give him directly, as Joey is too proud of himself to accept it. So, in order to trick him, Chandler asks Joey to play a game. In this game, Chandler gives Joey an array $ a_1, a_2, \dots, a_n $ ( $ n \geq 2 $ ) of positive integers ( $ a_i \ge 1 $ ). Joey can perform the following operation on the array any number of times: 1. Take two indices $ i $ and $ j $ ( $ 1 \le i < j \le n) $ . 2. Choose two integers $ x $ and $ y $ ( $ x, y \ge 1 $ ) such that $ x \cdot y = a_i \cdot a_j $ . 3. Replace $ a_i $ by $ x $ and $ a_j $ by $ y $ . In the end, Joey will get the money equal to the sum of elements of the final array. Find the maximum amount of money $ \mathrm{ans} $ Joey can get but print $ 2022 \cdot \mathrm{ans} $ . Why multiplied by $ 2022 $ ? Because we are never gonna see it again! It is guaranteed that the product of all the elements of the array $ a $ doesn't exceed $ 10^{12} $ .

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \leq t \leq 4000 $ ). Description of the test cases follows. The first line of each test case contains a single integer $ n $ ( $ 2 \leq n \leq 50 $ ) — the length of the array $ a $ . The second line contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \leq a_i \leq 10^6 $ ) — the array itself. It's guaranteed that the product of all $ a_i $ doesn't exceed $ 10^{12} $ (i. e. $ a_1 \cdot a_2 \cdot \ldots \cdot a_n \le 10^{12} $ ).

输出格式


For each test case, print the maximum money Joey can get multiplied by $ 2022 $ .

输入输出样例

输入样例 #1

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

输出样例 #1

28308
8088
2022000000004044

说明

In the first test case, Joey can do the following: 1. He chooses $ i = 1 $ and $ j = 2 $ (so he has $ a[i] \cdot a[j] = 6 $ ), chooses $ x = 6 $ and $ y = 1 $ and makes $ a[i] = 6 $ and $ a[j] = 1 $ . $ $[2, 3, 2] \xrightarrow[x = 6,\; y = 1]{i = 1,\; j = 2} [6, 1, 2] $ $ </li><li> He chooses $ i = 1 $ and $ j = 3 $ (so he has $ a\[i\] \\cdot a\[j\] = 12 $ ), chooses $ x = 12 $ and $ y = 1 $ and makes $ a\[i\] = 12 $ and $ a\[j\] = 1 $ . $ $ [6, 1, 2] \xrightarrow[x = 12,\; y = 1]{i = 1,\; j = 3} [12, 1, 1] $ $ </li></ol> The sum is $ 14 $ which is the maximum of all possible sums. The answer is $ 2022 \\cdot 14 = 28308$.

Input

题意翻译

- **题目翻译如下** ## 题目描述 Joey 很穷,因此他的朋友 Chandler 想要借给他一些钱。但是 Joey 的自尊心很强,为了不让他的自尊心受挫又能给他钱,Chandler 打算和他玩一个游戏。 在这个游戏中,Chandler 会给 Joey 一个数组 $a_1,a_2,\dots,a_n(n\ge 2,a_i \in \mathbb{N^+})$。Joey 可以对这个数组进行如下的操作任意次: 1. 选择一对 $ i $ 和 $ j $ ( $ 1 \le i < j \le n) $ . 2. 选择两个整数 $ x $ 和 $ y $ ( $ x, y \ge 1 $ ) 使得 $ x \cdot y = a_i \cdot a_j $ . 3. 将 $a_i, a_j$ 分别替换为 $x, y$. 最后, Joey 将得到的钱就是 $a$ 数组中所有值的和。即 Joey 所得的钱 $= \sum^{n}_{i=1}a_{i}$ . 你需要求出一个整数 $ans$,即 Joey 最多可以得到的钱,并输出 $2022 \cdot ans$ 。为什么要乘以 $2022$ 呢?因为我们再也见不到它了!(悲) 输入数据保证 $a$ 数组内所有数的乘积不超过 $10^{12}$,即 $\prod^{n}_{i=1}a_{i} \le 10^{12}$. ## 输入格式 输入包含多组测试数据。 - 第一行,一个整数 $T$,代表测试数据组数。 - 对于每一组测试数据,第一行为一个整数 $n(2 \leq n \leq 50)$,表示数组 $a$ 的长度。第二行为 $n$ 个整数 $a_1,a_2,\dots,a_n( 1 \leq a_i \leq 10^6 )$,表示 $a$ 数组。保证 $a$ 数组内所有数的乘积不超过 $10^{12}$,即 $\prod^{n}_{i=1}a_{i} \le 10^{12}$. ## 输出格式 共一行,一个整数,表示 Joey 最多可以得到的钱乘以 2022 后的值。 ## 提示 在测试样例的第一组测试数据中,Joey 可以这么做: - 他选择 $ i = 1 , j = 2 $ (可得 $ a[i] \cdot a[j] = 6 $ ), 使 $ x = 6, 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 = 3 $ (可得 $ a[i] \cdot a[j] = 12 $ ), 使 $ x = 12 , 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=14$ 元,所以输出应为 $14\times 2022 = 28308$.

Output

**题目大意**:

Joey因为很穷,他的朋友Chandler想通过玩游戏的方式给他一些钱。在游戏中,Chandler会给Joey一个正整数数组$a_1, a_2, \dots, a_n$($n \geq 2, a_i \in \mathbb{N^+}$)。Joey可以对数组进行任意次以下操作:

1. 选择两个下标$i$和$j$($1 \le i < j \le n$)。
2. 选择两个整数$x$和$y$($x, y \ge 1$),使得$x \cdot y = a_i \cdot a_j$。
3. 将$a_i$替换为$x$,$a_j$替换为$y$。

最后,Joey将得到数组中所有值的和作为钱。即Joey所得的钱$= \sum^{n}_{i=1}a_{i}$。

需要求出一个整数$ans$,即Joey最多可以得到的钱,并输出$2022 \cdot ans$。

**输入数据**保证$a$数组内所有数的乘积不超过$10^{12}$,即$\prod^{n}_{i=1}a_{i} \le 10^{12}$。

**输入格式**:

输入包含多组测试数据。

- 第一行,一个整数$T$,代表测试数据组数。
- 对于每一组测试数据,第一行为一个整数$n(2 \leq n \leq 50)$,表示数组$a$的长度。第二行为$n$个整数$a_1,a_2,\dots,a_n(1 \leq a_i \leq 10^6)$,表示$a$数组。保证$a$数组内所有数的乘积不超过$10^{12}$,即$\prod^{n}_{i=1}a_{i} \le 10^{12}$。

**输出格式**:

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

**样例**:

**输入**:

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

**输出**:

```
28308
8088
2022000000004044
```

**提示**:

在第一组测试数据中,Joey可以进行如下操作:

- 选择$i = 1, j = 2$(得到$a[i] \cdot a[j] = 6$),使$x = 6, 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 = 3$(得到$a[i] \cdot a[j] = 12$),使$x = 12, 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 = 14$元,所以输出应为$14 \times 2022 = 28308$。**题目大意**: Joey因为很穷,他的朋友Chandler想通过玩游戏的方式给他一些钱。在游戏中,Chandler会给Joey一个正整数数组$a_1, a_2, \dots, a_n$($n \geq 2, a_i \in \mathbb{N^+}$)。Joey可以对数组进行任意次以下操作: 1. 选择两个下标$i$和$j$($1 \le i < j \le n$)。 2. 选择两个整数$x$和$y$($x, y \ge 1$),使得$x \cdot y = a_i \cdot a_j$。 3. 将$a_i$替换为$x$,$a_j$替换为$y$。 最后,Joey将得到数组中所有值的和作为钱。即Joey所得的钱$= \sum^{n}_{i=1}a_{i}$。 需要求出一个整数$ans$,即Joey最多可以得到的钱,并输出$2022 \cdot ans$。 **输入数据**保证$a$数组内所有数的乘积不超过$10^{12}$,即$\prod^{n}_{i=1}a_{i} \le 10^{12}$。 **输入格式**: 输入包含多组测试数据。 - 第一行,一个整数$T$,代表测试数据组数。 - 对于每一组测试数据,第一行为一个整数$n(2 \leq n \leq 50)$,表示数组$a$的长度。第二行为$n$个整数$a_1,a_2,\dots,a_n(1 \leq a_i \leq 10^6)$,表示$a$数组。保证$a$数组内所有数的乘积不超过$10^{12}$,即$\prod^{n}_{i=1}a_{i} \le 10^{12}$。 **输出格式**: 共一行,一个整数,表示Joey最多可以得到的钱乘以2022后的值。 **样例**: **输入**: ``` 3 3 2 3 2 2 1 3 3 1000000 1000000 1 ``` **输出**: ``` 28308 8088 2022000000004044 ``` **提示**: 在第一组测试数据中,Joey可以进行如下操作: - 选择$i = 1, j = 2$(得到$a[i] \cdot a[j] = 6$),使$x = 6, 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 = 3$(得到$a[i] \cdot a[j] = 12$),使$x = 12, 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 = 14$元,所以输出应为$14 \times 2022 = 28308$。

加入题单

算法标签: