题意:长度为n的数轴 每次移动不能留在原地 输出一种走k次刚好走s的方法
很容易看出
k<=s||k*(n-1)>=s
的时候是有解的
然后后面怎么做呢?
大模拟是半天调不对的。。。思维是跟不上想不到的。。 就只能看题解混日子这个样子。。。。
由上面那个条件我们可以接着推出 如果第一步走了x的距离 那么两个式子就表示为了
k-1<=s&&(k-1)*(n-1)>=s-x&&x<=(n-1)
然后就没了
太难了。。。
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5 + 1000;
int main()
{
ios::sync_with_stdio(false);
ll n,k,s;
///n个地点 k次move 走s
while(cin>>n>>k>>s)
{
ll x=(n-1)*k;///k次最多能走的距离
if(s>x||k>s)
{
cout<<"NO"<<endl;
continue;
}
cout<<"YES"<<endl;
int now=1;
while(k--)
{
int d=min(s-k,n-1);
if(now+d<=n)
now+=d;
else
now-=d;
cout<<now<<" ";
s-=d;
}
cout<<endl;
}
return 0;
}