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

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 hasncards with integers lined up in front of him. Each integer is not less than 1, but not greater thanl. 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 thanl, 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 werencards, they contained integers from 1 tol, and after all magical actions he was left with a single card containing numberd.

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

,于千万年之中,于千万人之中,在时间无涯的荒野中,

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

相关文章:

你感兴趣的文章:

标签云: