codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

231B.md (2757B)


      1 Source: https://codeforces.com/problemset/problem/231/B
      2 
      3 B. Magic, Wizardry and Wonders
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 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.
     24 
     25 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.
     26 
     27 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.
     28 
     29 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*.
     30 
     31 Help Vasya to recover the initial set of cards with numbers.
     32 
     33 Input
     34 
     35 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.
     36 
     37 Output
     38 
     39 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.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 3 3 2
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 2 1 2
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 5 -4 3
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 -1
     65 ```
     66 
     67 Input
     68 
     69 ```
     70 5 -4 4
     71 ```
     72 
     73 Output
     74 
     75 ```
     76 2 4 1 4 1
     77 ```