Problem E Jolly Jumpers A sequence of n

按一下以編輯母片標題樣式 Problem E: Jolly Jumpers A sequence of n > 0 integers is called a jolly jumper if the • 按一下以編輯母片 absolute values of the difference between successive – 第二層take on all the values 1 through n-1. elements • 第三層 1 4 2 3 is a jolly jumper, because the For instance, – 第四層 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. 第三層 第四層 12/13/2021 第五層 12/13/2021 1 1

按一下以編輯母片標題樣式 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 第五層 41423 差值:按一下以編輯母片 3 2 1 (n=4,1~3都有出現,所以為jolly jumps) 5 1 4 2 -1 6 差值: 3 2第二層 3 5(n=5,1~4沒有都出現,所以不為jolly jumps) Sample Output Jolly 第三層 Not jolly 第四層 12/13/2021 第五層 12/13/2021 2 2


- Slides: 4