human
Find the sum of power of bit count raised to the power B | Function to calculate a ^ b mod m using fast - exponentiation method.
Function to calculate sum.
Itereate for all values of array A.
Calling fast - exponentiation and appending ans to sum.
Driver code ."
Solution in Python:
 What is a code to find the sum of power of bit count raised to the power B and the other steps required?
assistant
#Here is code to find the sum of power of bit count raised to the power B and the other steps required.
 def fastmod ( base , exp , mod ) :
	if ( exp == 0 ) :
		return 1 ;
	elif ( exp % 2 == 0 ) :
		ans = fastmod ( base , exp / 2 , mod ) ;
		return ( ans % mod * ans % mod ) % mod ;
	else :
		return ( fastmod ( base , exp - 1 , mod ) % mod * base % mod ) % mod ;
def findPowerSum ( n , ar ) :
	mod = int ( 1e9 ) + 7 ;
	sum = 0 ;
	for i in range ( n ) :
		base = bin ( ar [ i ] ) . count ( '1' ) ;
		exp = ar [ i ] ;
		sum += fastmod ( base , exp , mod ) ;
		sum %= mod ;
	return sum ;
if __name__ == " _ _ main _ _ " :
	n = 3 ;
	ar = [ 1 , 2 , 3 ] ;
	print ( findPowerSum ( n , ar ) ) ;