EASY MATH:BRUTE FORCE flow chart:
Chef is attending math classes. On each day, the teacher gives him homework. Yesterday, the teacher gave Chef a sequence of positive integers and asked him to find the maximum product of two different elements of this sequence. This homework was easy for Chef, since he knew that he should select the biggest two numbers.
However, today, the homework is a little bit different. Again, Chef has a sequence of positive integers A1,A2,…,AN, but he should find two different elements of this sequence such that the sum of digits (in base 10) of their product is maximum possible.
Chef thought, mistakenly, that he can still select the two largest elements and compute the sum of digits of their product. Show him that he is wrong by finding the correct answer ― the maximum possible sum of digits of a product of two different elements of the sequence A.
Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of the input contains a single integer N.
The second line contains N space-separated integers A1,A2,…,AN.
Output
For each test case, print a single line containing one integer ― the maximum sum of digits.
Constraints
1≤T≤100
2≤N≤100
1≤Ai≤104 for each valid i
Answers
Answered by
0
Answer:
tt
Explanation:
pls mark me as brainliest
Answered by
0
Explanation:
You know better than me
It is a Computer Science questions.
You ask to ur teacher
Similar questions