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.

排列 pp 是一个由 nn 个互不相同的正整数组成的有序集合 p1, p2, …, pnp_1,\,p_2,\,\dots,\,p_n,其中每个数均不超过 nn。我们将排列 pp 的第 ii 个元素记作 pip_i。我们称 nn 为排列 p1, p2, …, pnp_1,\,p_2,\,\dots,\,p_n 的大小(或长度)。

排列 p1, p2, …, pnp_1,\,p_2,\,\dots,\,p_n 的递减系数是指满足 pi>pi+1p_i > p_{i+1} 的下标 ii 的个数(其中 1≤i<n1 \le i < n)。

给定整数 nn 和 kk,你的任务是输出一个长度为 nn、递减系数恰好为 kk 的排列。

输入格式

The single line contains two space-separated integers: n, k (1 ≤ n ≤ 105, 0 ≤ k < n) — the permutation length and the decreasing coefficient.

单行包含两个以空格分隔的整数:nn 和 kk(1 ≤ n ≤ 1051 ≤ n ≤ 10^5,0 ≤ k < n0 ≤ 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测评打分。不知道怎么写?

首页