Minimum number of mails required to distribute all the questions | Java code to find the minimum number of mails ; Function returns the min no of mails required ; Using the formula derived above ; Driver Code ; no of questions ; no of students ; maximum no of questions a mail can hold ; Calling function
import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static double MinimumMail ( int n , int k , int x ) { double m = ( n - 1 ) + Math . ceil ( ( n - 1 ) * 1.0 / x ) * ( n - 1 ) + Math . ceil ( n * 1.0 / x ) * ( k - n ) ; return m ; } public static void main ( String [ ] args ) { int N = 4 ; int K = 9 ; int X = 2 ; System . out . print ( ( int ) MinimumMail ( N , K , X ) + "NEW_LINE"); } }