Distribute R , B beans such that each packet has at least 1 R and 1 B bean with absolute difference at most D | Function to check if it is possible to distribute R red and B blue beans in packets such that the difference between the beans in each packet is atmost D ; Check for the condition to distributing beans ; Print the answer ; Distribution is not possible ; Driver Code
function checkDistribution ( R , B , D ) { if ( Math . max ( R , B ) <= Math . min ( R , B ) * ( D + 1 ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } let R = 1 , B = 1 , D = 0 ; checkDistribution ( R , B , D ) ;