CF231B.Magic, Wizardry and Wonders

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

伟大的魔术师兼幻术师瓦西娅热爱各种奇迹与魔法。他只需挥动一次魔杖,就能将一个物体变成另一样东西。但众所周知,宇宙中没有比数字魔法更强大的魔法了。因此,瓦西娅酷爱数学,并花费大量时间将某些数字转变为其他数字。

今天早晨,他面前整齐地摆放着 nn 张写有整数的卡片。每个整数均不小于 11,且不大于 ll。每当瓦西娅挥动魔杖时,最右侧的两张卡片便会从队列中消失,而在它们原先的位置上会神奇地出现一张新卡片,其上的数字等于那两张消失卡片上数字之差(即左卡片数字减去右卡片数字)。瓦西娅对此过程非常感兴趣,于是不断挥动魔杖,直到桌上仅剩一张卡片为止。

例如,假设瓦西娅最初拥有的卡片为:4, 1, 1, 34,\ 1,\ 1,\ 3(从左到右列出)。那么第一次挥动魔杖后,队列变为:4, 1, −24,\ 1,\ -2;第二次挥动后变为:4, 34,\ 3;第三次挥动后,桌上便只剩一张数字为 11 的卡片。

请注意:尽管初始时所有卡片上的数字均满足 1≤数字≤l1 \leq \text{数字} \leq l,但后续生成的卡片上的数字可以是任意整数,对其大小没有任何限制。

现在已是傍晚,瓦西娅非常疲惫,想要将一切恢复原状,却已记不清清晨时手中究竟有哪些卡片。他只记得当时共有 nn 张卡片,每张卡片上的数字均为 11 到 ll 之间的整数,且经过全部魔法操作后,最终剩下的一张卡片上的数字为 dd。

请帮助瓦西娅复原最初的那组卡片上的数字。

输入格式

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.

单行包含三个以空格分隔的整数:nn(2 ≤ n ≤ 1002 \leq n \leq 100)—— 桌面上初始的卡片数量;dd(∣d∣ ≤ 104|d| \leq 10^4)—— 所有魔法操作后留在桌面上的卡片上的数字;ll(1 ≤ l ≤ 1001 \leq l \leq 100)—— 初始整数的取值范围限制。

输出格式

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.

如果瓦西娅弄错了,即不存在满足题目中所述要求的集合,则输出单个数字 -1;否则输出所求的包含 nn 个从 11 到 ll 的整数的集合。各整数之间用空格分隔。请按卡片上从左到右书写顺序输出这些整数。若存在多个满足条件的数集,输出任意一个即可。

输入输出样例

  • 输入#1

    3 3 2

    输出#1

    2 1 2
  • 输入#2

    5 -4 3

    输出#2

    -1
  • 输入#3

    5 -4 4

    输出#3

    2 4 1 4 1

输入解题思路,AI测评打分。不知道怎么写?

首页