#include #include #include using namespace std; int n; bool availables[101]; int picked[10]; bool solve(int d, int k) { if (k == 0) { return (d == 0); // only if total price equals 0 yen } int maxPricePickingUpK = 0; int pickedCount = 0; for (int i = n; i >= 1 && pickedCount < k; --i) { if (availables[i]) { maxPricePickingUpK += i; ++pickedCount; } } if (d > maxPricePickingUpK) { return false; } bool plausible = false; for (int i = 1; i <= n; ++i) { if (availables[i]) { availables[i] = false; picked[k - 1] = i; plausible |= solve(d - i, k - 1); availables[i] = true; if (plausible) { break; } } } return plausible; } int main() { int d, k; cin >> n; // sweets cin >> d; // total yen cin >> k; // count fill(&availables[1], &availables[n] + 1, true); if (n < k) { cout << -1 << endl; } bool solved = solve(d, k); if (solved) { vector v(&picked[0], &picked[k - 1] + 1); for (int i = k - 1; i >= 0; --i) { if (i != k - 1) { cout << " "; } cout << picked[i]; } cout << endl; } else { cout << -1 << endl; } return 0; }