###### Codeforces Round #143 (Div. 2)-B. Magic, Wizardry and Wonders

B. Magic, Wizardry and Wonders
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya the Great Magician and Conjurer loves all kinds of miracles and wizardry. In one wave of a magic wand he can turn an object into something else. But, as you all know, there is no better magic in the Universe than the magic of numbers. That's why Vasya adores math and spends a lot of time turning some numbers into some other ones.

This morning he has n cards with integers lined up in front of him. Each integer is not less than 1, but not greater than l. When Vasya waves his magic wand, two rightmost cards vanish from the line and a new card magically appears in their place. It contains the difference between the left and the right numbers on the two vanished cards. Vasya was very interested to know what would happen next, and so he waved with his magic wand on and on, until the table had a single card left.

Suppose that Vasya originally had the following cards: 4, 1, 1, 3 (listed from left to right). Then after the first wave the line would be: 4, 1, -2, and after the second one: 4, 3, and after the third one the table would have a single card with number 1.

Please note that in spite of the fact that initially all the numbers on the cards were not less than 1 and not greater than l, the numbers on the appearing cards can be anything, no restrictions are imposed on them.

It is now evening. Vasya is very tired and wants to return everything back, but does not remember which cards he had in the morning. He only remembers that there were n cards, they contained integers from 1 to l, and after all magical actions he was left with a single card containing number d.

Help Vasya to recover the initial set of cards with numbers.

Input

The single line contains three space-separated integers: n (2 ≤ n ≤ 100) — the initial number of cards on the table, d (|d| ≤ 104) — the number on the card that was left on the table after all the magical actions, and l (1 ≤ l ≤ 100) — the limits for the initial integers.

Output

If Vasya is mistaken, that is, if there doesn't exist a set that meets the requirements given in the statement, then print a single number -1, otherwise print the sought set containing n integers from 1 to l. Separate the integers by spaces. Print the integers in the order, in which they were written on the cards from left to right. If there are several suitable sets of numbers, you can print any of them.

Examples
input
3 3 2

output
2 1 2
input
5 -4 3

output
-1

input
5 -4 4

output
2 4 1 4 1

用maxs[i], mins[i]表示只剩i张卡片时第i张卡片上数字的最大值和最小值，对于题中给出的n, L.可以确定maxs[n] = L,

mins[n] = 1, 则可以推出maxs[n-1] = L - mins[n], mins[n-1] = 1 - maxs[n]以此类推，求出maxs和mins.

1.mins[2] <= a <= maxs[2]那么最初第一张卡牌的数字就可以确定为1,那么现在桌上有两张卡片，第二张卡片数字为1 - d.

2. mins[2] <= b <= maxs[2]那么最初第一张卡牌的数字就可以确定为l,那么现在桌上有两张卡片，第二张卡片数字为L- d.

#include <bits/stdc++.h>
#define maxn 105

using namespace std;
typedef long long ll;

int maxs[maxn], mins[maxn], ans[maxn];
int main(){

int n, d, l;

scanf("%d%d%d", &n, &d, &l);
mins[0] = 1;
maxs[0] = l;
for(int i = 1; i < n; i++){
maxs[i] = l - mins[i-1];
mins[i] = 1 - maxs[i-1];
}
if(d > maxs[n-1] || d < mins[n-1]){
puts("-1");
return 0;
}
for(int i = n-1; i >= 1; i--){
int k1 = l - d;
int k2 = 1 - d;
if(k1 >= mins[i-1] && k1 <= maxs[i-1]){
ans[i] = l;
d = k1;
}
else{
ans[i] = 1;
d = k2;
}
if(i == 1)
ans[i-1] = d;
}
printf("%d", ans[n-1]);
for(int i = n-2; i >= 0; i--)
printf(" %d", ans[i]);
puts("");

return 0;
}

#### Codeforces Round #471 (Div. 2)

2018-03-27 23:23:41

#### Codeforces Round #143 (Div. 2) (ABCD 思维场)

2015-07-18 18:58:10

#### Educational Codeforces Round 38 (Rated for Div. 2) B. Run For Your Prize

2018-02-17 13:35:37

#### Codeforces Round #471 div.2 ABC题解

2018-03-24 14:16:58

#### Codeforces Round #464 (Div. 2) B. Hamster Farm

2018-02-18 12:28:34

#### Codeforces Round #168 (Div. 1), problem: (B) Zero Tree, DFS

2013-02-25 13:21:26

#### Codeforces Educational Codeforces Round 41 (Rated for Div. 2) B. Lecture Sleep

2018-04-05 10:35:27

#### CF-Codeforces Round #483 (Div. 2) A~D

2018-05-16 00:48:25

#### Codeforces Round #467 (Div. 2) B. Vile Grasshoppers

2018-02-27 12:59:02

#### CF-Codeforces Round #483 (Div. 2)-D-XOR-pyramid

2018-05-16 01:15:04

## 不良信息举报

Codeforces Round #143 (Div. 2)-B. Magic, Wizardry and Wonders