题意:从1开始走,最多走到n,走k步,总长度为n,不能停留在原地,不能走出1-n,问是否有一组方案,若有则输出
n<=1e9,k<=2e5,s<=1e18
思路:无解的情况分为两种:总长度太大,步数太多
每次贪心从1走到n或从n走到1,但要注意给剩下的步数留出空间
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair
#define N 100010
#define M 200
#define MOD 998244353
#define eps 1e-8
#define pi acos(-1) int main()
{
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
ll n,k,s;
scanf("%lld%lld%lld",&n,&k,&s);
ll now=;
if(k>s||k*(n-)<s)
{
printf("NO\n");
return ;
}
printf("YES\n");
while(k)
{
ll t=min(n-,s-(k-));
if(now-t>) now-=t;
else now+=t;
printf("%lld ",now);
s-=t;
k--;
}
return ;
}