CF888D.Almost Identity Permutations
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 p__i = i.
Your task is to count the number of almost identity permutations for given numbers n and k.
一个大小为 n 的排列 p 是一个数组,其中从 1 到 n 的每个整数恰好出现一次。
若存在至少 n−k 个下标 i(1≤i≤n),使得 pi=i,则称该排列为几乎恒等排列(almost identity permutation)。
你的任务是:对给定的数 n 和 k,计算几乎恒等排列的个数。
输入格式
The first line contains two integers n and k (4 ≤ n ≤ 1000, 1 ≤ k ≤ 4).
第一行包含两个整数 n 和 k(4 ≤ n ≤ 1000,1 ≤ k ≤ 4)。
输出格式
Print the number of almost identity permutations for given n and k.
输出给定 n 和 k 下的“几乎恒等排列”(almost identity permutations)的数量。
输入输出样例
输入#1
4 1
输出#1
1
输入#2
4 2
输出#2
7
输入#3
5 3
输出#3
31
输入#4
5 4
输出#4
76
输入解题思路,AI测评打分。不知道怎么写?