Walking Between Houses-输出

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Input

The first line of the input contains three integers n

, k, s (2≤n≤109, 1≤k≤2⋅105, 1≤s≤1018

) — 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 k

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

Copy

10 2 15

Output

Copy

YES
10 4 

Input

Copy

10 9 45

Output

Copy

YES
10 1 10 1 2 1 2 1 6 

Input

Copy

10 9 81

Output

Copy

YES
10 1 10 1 10 1 10 1 10 

Input

Copy

10 9 82

Output

Copy

NO

 

题目大意:假设一条直线上有n步的距离 ,每次任意走多少步(不超过n),走k次,能否恰好走完s步

思路:开始时,可以算出他最多走多少步,最少走多少步(每次一步,也就是k步),s不再这个范围内直接NO

           算出他平均每次走的步数,当然,不会总是正好的,多出来的步数,remain=s%k,多出来的步数,就在前remain次中每次加一步即可。

           主要事输出问题

代码:

#include<iostream>
#include<cstring>
#include<vector>
#define pb push_back
#define ll long long
using namespace std;

vector<ll> route;

int main()
{
    ll n,k,s;
    cin>>n>>k>>s;
    ll  maxx=k*(n-1);
    if(maxx<s)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    if(k>s)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    ll beg=1;
    cout<<"YES"<<endl;
    ll temp=s/k;
    ll remain=s%k; //留下remain步

    for(int i=0;i<remain;i++)
        route.pb(temp+1);//混入前remain次中,每次一步
        
    for(int i=0;i<k-remain;i++)
        route.pb(temp);
        
    for(int i=0;i<route.size();i++)
    {
        if(beg+route[i]<=n)
        {
            cout<<beg+route[i]<<" ";
            beg=beg+route[i];
        }
        else
        {
            cout<<beg-route[i]<<" ";
            beg=beg-route[i];
        }
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值