human
Form N | function returns the minimum cost to form a n - copy string Here , x -> Cost to add / remove a single character ' G ' and y -> cost to append the string to itself.
base case : ro form a 1 - copy string we need tp perform an operation of type 1 ( i , e Add ).
case1 . Perform a Add operation on ( i - 1 ) copy string case2 . perform a type 2 operation on ( ( i + 1 ) / 2 ) - copy string.
case1 . Perform a Add operation on ( i - 1 ) - copy string case2 . Perform a type operation on ( i / 2 ) - copy string.
Driver code"
Solution in Python:
 ... Give me a code to form N and the other steps required?
assistant
#Here is code to form N and the other steps required.
 def findMinimumCost ( n , x , y ) :
	dp = [ 0 for i in range ( n + 1 ) ]
	dp [ 1 ] = x
	for i in range ( 2 , n + 1 ) :
		if i & 1 :
			dp [ i ] = min ( dp [ i - 1 ] + x , dp [ ( i + 1 ) // 2 ] + y + x )
		else :
			dp [ i ] = min ( dp [ i - 1 ] + x , dp [ i // 2 ] + y )
	return dp [ n ]
n , x , y = 4 , 2 , 1
print ( findMinimumCost ( n , x , y ) )