CPP program to find minimum and maximum no . of pairs
#include <bits/stdc++.h> NEW_LINE using namespace std ; void MinimumMaximumPairs ( int n , int m ) { int max_pairs = ( ( n - m + 1 ) * ( n - m ) ) / 2 ; int min_pairs = m * ( ( ( n - m ) / m + 1 ) * ( ( n - m ) / m ) ) / 2 + ceil ( ( n - m ) / double ( m ) ) * ( ( n - m ) % m ) ; cout << " Minimum ▁ no . ▁ of ▁ pairs ▁ = ▁ " << min_pairs << " STRNEWLINE " ; cout << " Maximum ▁ no . ▁ of ▁ pairs ▁ = ▁ " << max_pairs << " STRNEWLINE " ; }