Question: #include using namespace std; / / Function to calculate permutations ( N choose X ) long long Permutations ( long long N , long long
#include
using namespace std;
Function to calculate permutations N choose X
long long Permutationslong long N long long X
long long result ;
for long long i ; i X; i
result N i;
return result;
Function to calculate combinations N choose X
long long Combinationslong long N long long X
if X N X X N X;
long long result ;
for long long i ; i X; i
result N i;
result i ;
return result;
int main
Hospital emergency room problem
long long doctors ;
long long nurses ;
long long doctorsInBatch ;
long long nursesInBatch ;
a Ways to select doctors for the first set of doses
long long waysToSelectDoctors Combinationsdoctors doctorsInBatch;
cout a Ways to select doctors: waysToSelectDoctors endl;
b Ways to select nurses for the first set of doses
long long waysToSelectNurses Combinationsnurses nursesInBatch;
cout b Ways to select nurses: waysToSelectNurses endl;
c Ways to administer the first dose
long long totalPeople doctors nurses;
long long waysToAdministerFirstDose PermutationstotalPeople doctorsInBatch nursesInBatch;
cout c Ways to administer the first dose: waysToAdministerFirstDose endl;
d Ways to administer the second dose
long long remainingPeople totalPeople doctorsInBatch nursesInBatch;
long long waysToAdministerSecondDose PermutationsremainingPeople doctorsInBatch nursesInBatch;
cout d Ways to administer the second dose: waysToAdministerSecondDose endl;
e Total ways to administer all doses
long long totalWays waysToSelectDoctors waysToSelectNurses waysToAdministerFirstDose waysToAdministerSecondDose;
cout e Total ways to administer all doses: totalWays endl;
cout "Formula: waysToSelectDoctors waysToSelectNurses waysToAdministerFirstDose waysToAdministerSecondDose
endl;
Bonuses distribution problem
long long employees ;
long long bonuses ;
a Ways to distribute different bonuses
long long waysToDistributeBonuses Permutationsemployees bonuses;
cout "The number of ways to distribute bonuses to people if different is: waysToDistributeBonuses endl;
b Ways to distribute identical bonuses
long long waysToDistributeIdenticalBonuses Combinationsemployees bonuses;
cout If the bonuses are the same, there are: waysToDistributeIdenticalBonuses endl;
Test the functions
long long permTest Permutations;
cout
Permutations of things taken at a time: permTest endl;
long long combTest Combinations;
cout "Combinations of things taken at a time: combTest endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
