| 7 | using namespace std; |
| 8 | |
| 9 | int main() { |
| 10 | ios_base::sync_with_stdio(false); // Speeds up the execution time |
| 11 | cin.tie(NULL); |
| 12 | |
| 13 | lli t; // number of test cases |
| 14 | cin >> t; |
| 15 | |
| 16 | while(t--) { |
| 17 | int n, i, j, max = -1; |
| 18 | cin >> n; |
| 19 | |
| 20 | vector<int> sequence(n); |
| 21 | vector<int> sumOfProducts; // holds sum of products of two digits |
| 22 | |
| 23 | for(i = 0; i < n; i++) { |
| 24 | cin >> sequence[i]; |
| 25 | } |
| 26 | |
| 27 | // store sum of products of two digits |
| 28 | for(int i = 0; i < n - 1; i++) { |
| 29 | for(int j = i + 1; j < n; j++) { |
| 30 | int sum = 0; |
| 31 | int product = sequence[i] * sequence[j]; |
| 32 | |
| 33 | while(product > 0) { |
| 34 | sum += product % 10; |
| 35 | product /= 10; |
| 36 | } |
| 37 | |
| 38 | sumOfProducts.push_back(sum); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | // print the maximum value in the array |
| 43 | for(i = 0; i < sumOfProducts.size(); i++) { |
| 44 | if(sumOfProducts[i] > max) { |
| 45 | max = sumOfProducts[i]; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | cout << max << endl; |
| 50 | } |
| 51 | |
| 52 | return 0; |
| 53 | } |
nothing calls this directly
no outgoing calls
no test coverage detected