Walking Between Houses(CF-1015D)

Problem Description

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

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 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 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.

Input

The first line of the input contains three integers n, k, s (2≤n≤10^9, 1≤k≤2⋅10^5, 1≤s≤10^18) — the number of houses, the number of moves and the total distance you want to walk.

Output

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 kk integers hi (1≤hi≤n) on the second line, where hi is the house you visit on the i-th move.

For each j from 1 to k−1 the following condition should be satisfied: hj≠hj+1. Also h1≠1 should be satisfied.

Examples

Input

10 2 15

Output

YES
10 4 

Input

10 9 45

Output

YES
10 1 10 1 2 1 2 1 6 

Input

10 9 81

Output

YES
10 1 10 1 10 1 10 1 10 

Input

10 9 82

Output

NO

题意:给出 n 个房子,要走过的房子数 k,以及要求走过的距离 s,两个房子的距离是房号之差,求能否使得走过k个房子的距离等于要求走过的距离,如果能,再输出走过的房号。

思路:先求 k 步下最短路程与最长路程为多少,如果 s 不在这个区间,那么就无法满足条件,输出 NO,然后再将 s 分成 k 份,直接模拟即可。

Source Program

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<ctime>
#include<vector>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define N 1000005
#define MOD 123
#define E 1e-6
using namespace std;
long long n,k,s;
vector<long long> v,res;
int main()
{
    cin>>n>>k>>s;

    long long maxx=k*(n-1);//最大距离
    if(maxx<s)//最大距离小于要求距离
    {
        cout<<"NO"<<endl;
        return 0;
    }
    if(s<k)//k步走的路程大于要求路程
    {
        cout<<"NO"<<endl;
        return 0;
    }

    long long temp=s/k;//分成k份
    long long rem=s%k;
    for(long long i=0;i<rem;i++)
        v.push_back(temp+1);

    for(long long i=0;i<k-rem;i++)
        v.push_back(temp);

    long long beg=1;
    cout<<"YES"<<endl;
    for(long long i=0;i<v.size();i++)
    {
        if(beg+v[i]<=n)
        {
            cout<<beg+v[i]<<" ";
            beg+=v[i];
        }
        else
        {
            cout<<beg-v[i]<<" ";
            beg-=v[i];
        }
    }
    cout<<endl;


    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值