Saving Marvel mettl code

Can anyone help me out to solve this problem

Saving Marvel

In a parallel universe called Marvel an infectious viral disease has been
spreading at a very fast rate. Dr Strange is trying to create a potion that would
prevent people from catching the disease and would also cure the ones
diseased already

He knows that the cure is a potion which is a mixture of N chemicals and is K
liters in volume. He does not know the amount of each chemical that must be
added and hence is experimenting on the same

As Dr. Strange’s assistant, you help him in his task and ask him on how to
prepare the potion, to which he replies

  1. Chemicals must be added in the increasing order of their labels
  2. The amount of chemicals being added must be between 1 and L, where L is
    the amount of mixture obtained till that step
  3. Exactly 1 liter of the first chemical must be taken

You, along with being a biologist, are a good programmer and mathematician
and hence, decide to find the number of potions possible in accordance with
Dr. Strange’s instructions using a computer program

Input Specification:
input1: An integer value N denoting the number of chemicals
input2: An integer value K denoting the total amount of chemical to
be added

Output Specification:
Return the number of potions possible in accordance with Dr.
Strange’s instructions

Example 1:

input1: 2
input2: 2

Example 1:
input1: 2
input2: 2

Output: 1

Explanation:
The only possible way for the above scenario is
1 chemical 1 - 1L, chemical 2 - 1L
Since here is only 1 possible way, hence, 1 will be returned as the answer

Example 2:
input1: 5
input2: 10

Output: 6

Explanation:
The total possible ways for the above scenario are

  1. chemical 1 - 1L, chemical 2 - 1L, chemical 3 - 2L, chemical 4 - 4L, chemical 5- 2L

  2. chemical 1 - 1L. chemical 2 - 1L, chemical 3 - 2L, chemical 4 - 3L, chemical 5- 3L

  3. chemical 1 - 1L, chemical 2 - 1L, chemical 3 - 2L, chemical 4 - 2L, chemical 5- 4L

  4. chemical 1 - 1L, chemical 2 - 1L, chemical 3 - 1L, chemical 4 - 3L, chemical 5- 4L

  5. chemical 1 - 1L. chemical 2 - 1L, chemical 3 - 1L, chemical 4 - 2L, chemical 5- 5L

  6. chemical 1 - 1L, chemical 2 - 1L. chemical 3 - 2L. chemical 4 - 1L. chemical 5- 5L

Since here are only 6 possible ways, hence 6 will be returned as the answer

5 Likes

include <stdio.h>
int main()
{
int N,K;
printf(“Enter value of N: “);
scanf(”%d”,&N);
printf(“Enter value of K: “);
scanf(”%d”,&K);
int marvel = K - N;
printf(“No of positions possible is %d\n”,++marvel);
}