Maximize count of distinct profits possible by N transactions | C ++ program for the above approach ; Function to count distinct profits possible ; Stores the minimum total profit ; Stores the maximum total profit ; Return count of distinct profits ; Driver code ; Input ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; int numberOfWays ( int N , int X , int Y ) { int S1 = ( N - 1 ) * X + Y ; int S2 = ( N - 1 ) * Y + X ; return ( S2 - S1 + 1 ) ; } int main ( ) { int N = 3 ; int X = 13 ; int Y = 15 ; cout << numberOfWays ( N , X , Y ) ; return 0 ; }