CF1015D.Walking Between Houses

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn houses in a row. They are numbered from 11 to nn in order from left to right. Initially you are in the house 11.

You have to perform kk moves to other house. In one move you go from your current house to some other house. You can't stay where you are (i.e., in each move the new house differs from the current house). If you go from the house xx to the house yy, the total distance you walked increases by ∣x−y∣|x-y| units of distance, where ∣a∣|a| is the absolute value of aa. It is possible to visit the same house multiple times (but you can't visit the same house in sequence).

Your goal is to walk exactly ss units of distance in total.

If it is impossible, print "NO". Otherwise print "YES" and any of the ways to do that. Remember that you should do exactly kk moves.

一行中有 nn 座房子,从左到右依次编号为 11 到 nn。初始时你位于第 11 号房子。

你需要恰好执行 kk 次移动,每次移动都必须前往另一座房子(即不能停留在当前房子,每次移动后所在房子编号必须与移动前不同)。若你从房子 xx 移动到房子 yy,则总行走距离增加 ∣x−y∣|x-y| 个单位长度,其中 ∣a∣|a| 表示 aa 的绝对值。允许重复访问同一座房子(但不允许连续两次停留在同一座房子)。

你的目标是使总行走距离恰好为 ss 个单位长度。

若无法实现,输出 "NO";否则输出 "YES",并给出任意一种满足条件的移动方案。注意:你必须恰好执行 kk 次移动。

输入格式

The first line of the input contains three integers nn, kk, ss (2≤n≤1092 \le n \le 10^9, 1≤k≤2⋅1051 \le k \le 2 \cdot 10^5, 1≤s≤10181 \le s \le 10^{18}) — the number of houses, the number of moves and the total distance you want to walk.

输入的第一行包含三个整数 nn、kk、ss(2≤n≤1092 \le n \le 10^9,1≤k≤2⋅1051 \le k \le 2 \cdot 10^5,1≤s≤10181 \le s \le 10^{18})——分别表示房屋数量、移动次数以及你希望行走的总距离。

输出格式

If you cannot perform kk moves with total walking distance equal to ss, print "NO".

Otherwise print "YES" on the first line and then print exactly kk integers hih_i (1≤hi≤n1 \le h_i \le n) on the second line, where hih_i is the house you visit on the ii-th move.

For each jj from 11 to k−1k-1 the following condition should be satisfied: hj≠hj+1h_j \ne h_{j + 1}. Also h1≠1h_1 \ne 1 should be satisfied.

如果无法通过 kk 次移动使得总行走距离恰好等于 ss,则输出 "NO"。

否则,在第一行输出 "YES",并在第二行输出恰好 kk 个整数 hih_i(1≤hi≤n1 \le h_i \le n),其中 hih_i 表示第 ii 次移动所访问的房子编号。

对于每个从 11 到 k−1k-1 的 jj,需满足条件:hj≠hj+1h_j \ne h_{j + 1}。此外,还需满足 h1≠1h_1 \ne 1。

输入输出样例

  • 输入#1

    10 2 15

    输出#1

    YES
    10 4
  • 输入#2

    10 9 45

    输出#2

    YES
    10 1 10 1 2 1 2 1 6
  • 输入#3

    10 9 81

    输出#3

    YES
    10 1 10 1 10 1 10 1 10
  • 输入#4

    10 9 82

    输出#4

    NO

输入解题思路,AI测评打分。不知道怎么写?

首页