301509: CF285A. Slightly Decreasing Permutations

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Slightly Decreasing Permutations

题意翻译

给定两个整数$n,k(1 \le n \le 10^5,0 \le k < n)$,请你找到一个长度为 $n$ 排列$^{*}$ $p(p_1,p_2,...,p_n)$,满足恰好有 $k$ 个 $i(1\le i < n)$ 使得 $p_i>p_{i+1}$ 成立。 请输出你所找到的排列。数据保证有解。如果有多个解,请输出任意一个。 *:排列 $p$ 是一个有序正整数列$p_1,p_2,...,p_n$,满足数列中所有数都不相同,且每个数的都小于 $n$。我们把排列中第 $i$ 个数叫做 $p_i$,把 $n$ 叫做排列 $p_1,p_2,...,p_n$ 的长度。

题目描述

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&lt;n) $ , that $ p_{i}&gt;p_{i+1} $ . You have numbers $ n $ and $ k $ . Your task is to print the permutation of length $ n $ with decreasing coefficient $ k $ .

输入输出格式

输入格式


The single line contains two space-separated integers: $ n,k\ (1<=n<=10^{5},0<=k&lt;n) $ — the permutation length and the decreasing coefficient.

输出格式


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.

输入输出样例

输入样例 #1

5 2

输出样例 #1

1 5 2 4 3

输入样例 #2

3 0

输出样例 #2

1 2 3

输入样例 #3

3 2

输出样例 #3

3 2 1

Input

题意翻译

给定两个整数$n,k(1 \le n \le 10^5,0 \le k < n)$,请你找到一个长度为 $n$ 排列$^{*}$ $p(p_1,p_2,...,p_n)$,满足恰好有 $k$ 个 $i(1\le i < n)$ 使得 $p_i>p_{i+1}$ 成立。 请输出你所找到的排列。数据保证有解。如果有多个解,请输出任意一个。 *:排列 $p$ 是一个有序正整数列$p_1,p_2,...,p_n$,满足数列中所有数都不相同,且每个数的都小于 $n$。我们把排列中第 $i$ 个数叫做 $p_i$,把 $n$ 叫做排列 $p_1,p_2,...,p_n$ 的长度。

加入题单

算法标签: