human
Ways to color a skewed tree such that parent and child have different colors | fast_way is recursive method to calculate power.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to ways to color a skewed tree such that parent and child have different colors and the other steps required.
 def fastPow ( N , K ) :
	if ( K == 0 ) :
		return 1 ;
	temp = fastPow ( N , int ( K / 2 ) ) ;
	if ( K % 2 == 0 ) :
		return temp * temp ;
	else :
		return N * temp * temp ;
def countWays ( N , K ) :
	return K * fastPow ( K - 1 , N - 1 ) ;
N = 3 ;
K = 3 ;
print ( countWays ( N , K ) ) ;