Jolly Jumpers

и задачки для интервью.
User avatar
IvanGrozniy
Уже с Приветом
Posts: 10526
Joined: 04 Feb 2004 14:14
Location: Edgewater, NJ

Jolly Jumpers

Post by IvanGrozniy »

Есть задачка:
A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1. For instance,

1 4 2 3

is a jolly jumper, because the absolutes differences are 3, 2, and 1 respectively. The definition implies that any sequence of a single integer is a jolly jumper. You are to write a program to determine whether or not each of a number of sequences is a jolly jumper.
Input
Each line of input contains an integer n <= 3000 followed by n integers representing the sequence.

Output
For each line of input, generate a line of output saying "Jolly" or "Not jolly".
Sample Input
4 1 4 2 3
5 1 4 2 -1 6

Sample Output
Jolly
Not jolly


Судя по объяснению, входные для входных данных 4 1 4 2 3, количество чисел n = 5, то есть разница между числами должна быть от 1 до n-1=4. Число 4 нигде не выходит (что противоречит предложению take on all the values 1 through n-1), а вывод всё равно получается Jolly.
Если я не прав, объясните, пожалуйста, чего я не понимаю в условии задачи.
User avatar
venco
Уже с Приветом
Posts: 2001
Joined: 10 Nov 2004 00:34
Location: MD

Re: Jolly Jumpers

Post by venco »

Each line of input contains an integer n (1) <= 3000 followed by n integers (n more) representing the sequence
Lev888
Новичок
Posts: 55
Joined: 09 Sep 2005 17:23
Location: Vladivostok --> Boston 1991

Post by Lev888 »

"Each line of input contains an integer n <= 3000 followed by n integers representing the sequence." means the first number is not a member of the input sequence.

Lev
Sin lies only in hurting other people unnecessarily. All other "sins" are invented nonsense. - R. Heinlein
User avatar
IvanGrozniy
Уже с Приветом
Posts: 10526
Joined: 04 Feb 2004 14:14
Location: Edgewater, NJ

Post by IvanGrozniy »

Спасибо, пропустил я это.
User avatar
rvd
Уже с Приветом
Posts: 1418
Joined: 04 Aug 2005 19:12

Post by rvd »

Sample Input
4 1 4 2 3

Sample Output
Jolly

разве?
Лучшее - враг хорошего!
User avatar
Artemk
Уже с Приветом
Posts: 4790
Joined: 21 Jul 2002 21:55
Location: Minsk -> Louisville, KY

Post by Artemk »

rvd wrote:
Sample Input
4 1 4 2 3

Sample Output
Jolly

разве?

Да, а почему нет?
4 1 4 2 3
4 числа 1 3 4 2 2 1 3 [/color]
Разницы между числами - 3, 2, 1 = Jolly
Мне повезло, я такой как все. Я работаю в офисе.

Return to “Головоломки”