310700: CF1873B. Good Kid

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

Description

B. Good Kidtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Slavic is preparing a present for a friend's birthday. He has an array $a$ of $n$ digits and the present will be the product of all these digits. Because Slavic is a good kid who wants to make the biggest product possible, he wants to add $1$ to exactly one of his digits.

What is the maximum product Slavic can make?

Input

The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \leq n \leq 9$) — the number of digits.

The second line of each test case contains $n$ space-separated integers $a_i$ ($0 \leq a_i \leq 9$) — the digits in the array.

Output

For each test case, output a single integer — the maximum product Slavic can make, by adding $1$ to exactly one of his digits.

ExampleInput
4
4
2 2 1 2
3
0 1 2
5
4 3 2 3 4
9
9 9 9 9 9 9 9 9 9
Output
16
2
432
430467210

Output

题目大意:
斯拉夫正在为朋友的生日准备礼物。他有一个包含n个数字的数组a,礼物将是这些数字的乘积。因为斯拉夫是一个想要制造尽可能大的乘积的好孩子,他想要将1加到恰好一个数字上。问题是,斯拉夫能制造的最大乘积是多少?

输入输出数据格式:
输入:
- 第一行包含一个整数t(1≤t≤10^4),表示测试用例的数量。
- 每个测试用例的第一行包含一个整数n(1≤n≤9),表示数字的数量。
- 每个测试用例的第二行包含n个空格分隔的整数a_i(0≤a_i≤9),表示数组中的数字。

输出:
- 对于每个测试用例,输出一个整数——通过将1加到恰好一个数字上,斯拉夫可以制造的最大乘积。题目大意: 斯拉夫正在为朋友的生日准备礼物。他有一个包含n个数字的数组a,礼物将是这些数字的乘积。因为斯拉夫是一个想要制造尽可能大的乘积的好孩子,他想要将1加到恰好一个数字上。问题是,斯拉夫能制造的最大乘积是多少? 输入输出数据格式: 输入: - 第一行包含一个整数t(1≤t≤10^4),表示测试用例的数量。 - 每个测试用例的第一行包含一个整数n(1≤n≤9),表示数字的数量。 - 每个测试用例的第二行包含n个空格分隔的整数a_i(0≤a_i≤9),表示数组中的数字。 输出: - 对于每个测试用例,输出一个整数——通过将1加到恰好一个数字上,斯拉夫可以制造的最大乘积。

加入题单

算法标签: