Preparando MOJI

Almost Identity Permutations

2000ms 262144K

Description:

A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.

Let's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 ≤ i ≤ n) such that pi = i.

Your task is to count the number of almost identity permutations for given numbers n and k.

Input:

The first line contains two integers n and k (4 ≤ n ≤ 1000, 1 ≤ k ≤ 4).

Output:

Print the number of almost identity permutations for given n and k.

Sample Input:

4 1

Sample Output:

1

Sample Input:

4 2

Sample Output:

7

Sample Input:

5 3

Sample Output:

31

Sample Input:

5 4

Sample Output:

76

Informação

Codeforces

Provedor Codeforces

Código CF888D

Tags

combinatoricsdpmath

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:20:26

Relacionados

Nada ainda