#C3357. Book Arrangements

    ID: 46775 Type: Default 1000ms 256MiB

Book Arrangements

Book Arrangements

You are given n books and an integer k. Your task is to determine the number of ways to arrange exactly k books out of the n books. The order of the selected books matters, hence this is a permutation problem.

The number of arrangements can be computed using the permutation formula:

$$P(n, k) = n \times (n-1) \times \cdots \times (n-k+1)$$

Note the following conditions:

  • If k > n or any of n/k is negative, then the result should be 0.
  • If k = 0, there is exactly one way (choosing no books).

Make sure your program reads input from standard input and writes the result to standard output.

inputFormat

The input consists of a single line containing two integers n and k separated by a space.

n represents the total number of books, and k represents the number of books to arrange.

outputFormat

Output a single integer which is the number of ways to arrange exactly k books out of n books, computed as:

$$P(n, k) = n \times (n-1) \times \cdots \times (n-k+1)$$

If the input conditions are not met (k > n or negative inputs), output 0.

## sample
5 3
60