http://codeforces.com/contest/1015/problem/D
题意:有n个房子排成一列,编号为1~n,起初你在第1个房子里,现在你要进行k次移动,每次移动一都可以从一个房子i移动到另外一个其他的房子j里(i != j),移动的距离为|j - i|。问你进过k次移动后,移动的总和可以刚好是s吗?若可以则输出YES并依次输出每次到达的房子的编号,否则输出NO。
思路:每次移动的大小为 s与k的差值 和 n-1 中的较小值,使得s和k尽快的相等
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
using namespace std;
#define ll long long
ll N, K, S;
int main()
{
cin >>N >> K >> S;
if((N - 1) * K < S || S < K) {
printf("NO\n");
return 0;
}
printf("YES\n");
int ans = 1;
while(K --) {
int wer = min(S - K, N - 1);
S -= wer;
if(ans + wer <= N) ans += wer;
else ans -= wer;
printf("%d ", ans);
}
printf("\n");
return 0;
}