305363: CF1015D. Walking Between Houses
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Walking Between Houses
题意翻译
### 题目描述 在一条路上,$n$个房子被排成一排,从从左到右编号为$1-n$。一开始,你站在$1$号房子前。 你需要移动到其他的房子$k$次。每一次移动,你不能原地不动(即移动后与移动前,你必须在不同的房子前面)。如果你从$x$房子移动到$y$房子,那么你走过的距离就是$\left| x-y \right|$,这里$\left| a \right|$表示$a$的绝对值。当然,你可以访问同一个房子多次(只要不连续就行了) 你的目标是一共走$s$个单位长度。 如果是不可能的,输出$NO$,否则输出$YES$,并输出任意一种移动方案,记住你只能走恰好$k$次。 ### 输入输出格式 #### 输入格式 第一行包括三个整数$n,k,s$,分别表示房子的数目,你要移动的次数,和你一共要走的距离。其中$2\leqslant n\leqslant 10^9,1\leqslant k\leqslant 2\times 10^5,1\leqslant s\leqslant 10^{18}$ #### 输出格式 如果不能用恰好$k$次移动走过$s$的距离,输出$NO$。 否则第一行输出$YES$,然后在第二行输出恰好$k$个整数$h_i\left( 1\leqslant h_i\leqslant n \right) $,$h_i$就是你第$i$次移动到的房子。 对于每个$h_j\left( 1\leqslant j\leqslant k-1 \right) $应该满足$h_j\ne h_{j+1}$,当然如果$h_1=1$,你就$吃翔$了。题目描述
There are $ n $ houses in a row. They are numbered from $ 1 $ to $ n $ in order from left to right. Initially you are in the house $ 1 $ . You have to perform $ k $ 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 $ x $ to the house $ y $ , the total distance you walked increases by $ |x-y| $ units of distance, where $ |a| $ is the absolute value of $ a $ . 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 $ s $ 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 $ k $ moves.输入输出格式
输入格式
The first line of the input contains three integers $ n $ , $ k $ , $ s $ ( $ 2 \le n \le 10^9 $ , $ 1 \le k \le 2 \cdot 10^5 $ , $ 1 \le s \le 10^{18} $ ) — the number of houses, the number of moves and the total distance you want to walk.
输出格式
If you cannot perform $ k $ moves with total walking distance equal to $ s $ , print "NO". Otherwise print "YES" on the first line and then print exactly $ k $ integers $ h_i $ ( $ 1 \le h_i \le n $ ) on the second line, where $ h_i $ is the house you visit on the $ i $ -th move. For each $ j $ from $ 1 $ to $ k-1 $ the following condition should be satisfied: $ h_j \ne h_{j + 1} $ . Also $ h_1 \ne 1 $ should be satisfied.
输入输出样例
输入样例 #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