CF285A.Slightly Decreasing Permutations
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Permutation p is an ordered set of integers _p_1, _p_2, ..., p__n, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p__i. We'll call number n the size or the length of permutation _p_1, _p_2, ..., p__n.
The decreasing coefficient of permutation _p_1, _p_2, ..., p__n is the number of such i (1 ≤ i < n), that p__i > p__i + 1.
You have numbers n and k. Your task is to print the permutation of length n with decreasing coefficient k.
排列 p 是一个由 n 个互不相同的正整数组成的有序集合 p1,p2,…,pn,其中每个数均不超过 n。我们将排列 p 的第 i 个元素记作 pi。我们称 n 为排列 p1,p2,…,pn 的大小(或长度)。
排列 p1,p2,…,pn 的递减系数是指满足 pi>pi+1 的下标 i 的个数(其中 1≤i<n)。
给定整数 n 和 k,你的任务是输出一个长度为 n、递减系数恰好为 k 的排列。
输入格式
The single line contains two space-separated integers: n, k (1 ≤ n ≤ 105, 0 ≤ k < n) — the permutation length and the decreasing coefficient.
单行包含两个以空格分隔的整数:n 和 k(1 ≤ n ≤ 105,0 ≤ k < n)—— 分别表示排列的长度和递减系数。
输出格式
In a single line print n space-separated integers: _p_1, _p_2, ..., p__n — the permutation of length n with decreasing coefficient k.
If there are several permutations that meet this condition, print any of them. It is guaranteed that the permutation with the sought parameters exists.
在一行中输出 n 个以空格分隔的整数:_p_1, _p_2, ..., p__n —— 这是一个长度为 n 且递减系数为 k 的排列。
若存在多个满足该条件的排列,输出其中任意一个即可。题目保证所求参数对应的排列一定存在。
输入输出样例
输入#1
5 2
输出#1
1 5 2 4 3
输入#2
3 0
输出#2
1 2 3
输入#3
3 2
输出#3
3 2 1
输入解题思路,AI测评打分。不知道怎么写?