human
Count pairs from an array having equal sum and quotient | Function to count all pairs ( i , j ) such that a [ i ] + [ j ] = a [ i ] / a [ j ].
Stores total count of pairs.
Generate all possible pairs.
If a valid pair is found.
Increment count.
Return the final count.
Driver Code"
Solution in Python:
assistant
#Here is code to count pairs from an array having equal sum and quotient and the other steps required.
 def countPairs ( a , n ) :
	count = 0
	for i in range ( n ) :
		for j in range ( i + 1 , n ) :
			if ( a [ j ] != 0 and a [ i ] % a [ j ] == 0 ) :
				if ( ( a [ i ] + a [ j ] ) == ( a [ i ] // a [ j ] ) ) :
					count += 1
	return count
if __name__ == ' _ _ main _ _ ' :
	arr = [ - 4 , - 3 , 0 , 2 , 1 ]
	N = len ( arr )
	print ( countPairs ( arr , N ) )