#C10265. Flower Arrangement in Grid
Flower Arrangement in Grid
Flower Arrangement in Grid
Given an n × n garden grid, determine the number of ways to place exactly k flowers such that no two flowers share the same row or column. In each valid arrangement, exactly k rows and exactly k columns are chosen from the n available rows and columns, and the flowers are placed in a one-to-one matching between these rows and columns.
The total number of arrangements is given by the formula: $$\binom{n}{k}^2 \times k!$$. If any of the conditions fails (i.e. if k > n, k<0, or n<1), then the answer is 0.
inputFormat
The input consists of two integers n and k separated by space in a single line read from standard input.
outputFormat
Output a single integer representing the number of valid flower arrangements. The output should be printed to standard output.## sample
4 2
72