#K34007. Soldier Distribution Problem

    ID: 25213 Type: Default 1000ms 256MiB

Soldier Distribution Problem

Soldier Distribution Problem

Given two integers, N and S, representing the number of ranks and the number of soldiers respectively, determine the number of ways to distribute the soldiers among the ranks. Each rank may receive zero or more soldiers, but the total number of soldiers must be exactly S.

This is a combinatorial problem that can be solved using the stars and bars method. The number of ways is given by the formula:

$$ \binom{S+N-1}{N-1} $$

For instance, if N = 3 and S = 5, the answer is 21.

inputFormat

The input is given via standard input (stdin) and consists of a single line containing two space-separated integers:

  • N: the number of ranks
  • S: the number of soldiers

Constraints: N and S are non-negative integers, and the resulting combination will fit in the appropriate data type.

outputFormat

Output a single integer which is the number of ways to distribute S soldiers among N ranks. The output should be written to standard output (stdout).

## sample
3 5
21