Count of Binary Strings possible as per given conditions | Java program to implement the above approach ; Function to generate maximum possible strings that can be generated ; Maximum possible strings ; Driver Code
import java . io . * ; import java . util . * ; class GFG { static long countStrings ( long A , long B , long K ) { long X = ( A + B ) / ( K + 1 ) ; return ( Math . min ( A , Math . min ( B , X ) ) * ( K + 1 ) ) ; } public static void main ( String [ ] args ) { long N = 101 , M = 231 , K = 15 ; System . out . print ( countStrings ( N , M , K ) ) ; } }