class Program {
static void countProductPairs(int[] arr, int[] pairs) {
int evenPairs = 0;
int oddPairs = 0;
for (int i = 0; i < arr.length; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] * arr[j] % 2 == 0) {
evenPairs++;
} else {
oddPairs++;
}
}
}
pairs[0] = evenPairs * 2;
pairs[1] = oddPairs * 2;
}
public static void main(String[] args) {
int[] arr = {1, 8, 5};
int[] pairs = new int[2];
// The pairs are: (1, 8), (1, 5), (8, 1), (8, 5), (5, 1), (5, 8)
// Pairs with Even product: (1, 8), (8, 1), (8, 5), (5, 8) = 4
// Total pairs with Odd product: (1, 5), (1, 5) = 2
countProductPairs(arr, pairs);
System.out.println("Total Even Product Pairs = " + pairs[0] );
System.out.println("Total Odd Product Pairs = " + pairs[1]);
}
}
/*
run:
Total Even Product Pairs = 4
Total Odd Product Pairs = 2
*/