Minimum number of mails required to distribute all the questions | C ++ 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
#include <bits/stdc++.h> NEW_LINE #define ll  long long int NEW_LINE using namespace std ; long long int MinimumMail ( int n , int k , int x ) { ll m = ( n - 1 ) + ( ll ) ceil ( ( n - 1 ) * 1.0 / x ) * ( n - 1 ) + ( ll ) ceil ( n * 1.0 / x ) * ( k - n ) ; return m ; } int main ( ) { int N = 4 ; int K = 9 ; int X = 2 ; cout << MinimumMail ( N , K , X ) << endl ; return 0 ; }