CF1731A.Joey Takes Money
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 a1,a2,…,an ( n≥2 ) of positive integers ( ai≥1 ).
Joey can perform the following operation on the array any number of times:
- Take two indices i and j ( 1≤i<j≤n) .
- Choose two integers x and y ( x,y≥1 ) such that x⋅y=ai⋅aj .
- Replace ai by x and aj 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 ans Joey can get but print 2022⋅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 1012 .
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤4000 ). Description of the test cases follows.
The first line of each test case contains a single integer n ( 2≤n≤50 ) — the length of the array a .
The second line contains n integers a1,a2,…,an ( 1≤ai≤106 ) — the array itself.
It's guaranteed that the product of all ai doesn't exceed 1012 (i. e. a1⋅a2⋅…⋅an≤1012 ).
输出格式
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:
- He chooses i=1 and j=2 (so he has a[i]⋅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] $$
- 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] $$