Make A , B and C equal by adding total value N to them | Java program to distribute integer N among A , B , C such that they become equal ; Find maximum among the three elements ; Summation of three elements ; Check if difference is divisible by 3 ; Driver code
class GFG { static void distributeN ( int A , int B , int C , int n ) { int max1 = Math . max ( A , B ) ; int max2 = Math . max ( B , C ) ; int maximum = Math . max ( max1 , max2 ) ; int sum = A + B + C ; int p = ( 3 * maximum ) - sum ; int diff = n - p ; if ( diff < 0 diff % 3 == 0 ) System . out . print ( " No " ) ; else System . out . print ( " Yes " ) ; } public static void main ( String [ ] args ) { int A = 10 , B = 20 ; int C = 15 , n = 14 ; distributeN ( A , B , C , n ) ; } }