Count ways to divide C in two parts and add to A and B to make A strictly greater than B | Function to count the number of ways to divide C into two parts and add to A and B such that A is strictly greater than B ; Minimum value added to A to satisfy the given relation ; Number of different values of A , i . e . , number of ways to divide C ; Driver code
function countWays ( A , B , C ) { var minAddA = Math . max ( 0 , parseInt ( ( C + B - A + 2 ) / 2 ) ) ; var count_ways = Math . max ( C - minAddA + 1 , 0 ) ; return count_ways ; } var A = 3 , B = 5 , C = 5 ; document . write ( countWays ( A , B , C ) ) ;