Presentation is loading. Please wait.

Presentation is loading. Please wait.

按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 Problem E: Jolly Jumpers A sequence of n > 0 integers is called a jolly.

Similar presentations


Presentation on theme: "按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 Problem E: Jolly Jumpers A sequence of n > 0 integers is called a jolly."— Presentation transcript:

1 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 Problem E: Jolly Jumpers 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.

2 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 2 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 2 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 差值: 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

3 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 3 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 3 重點: 將其後的兩數的差值存下 再判斷差值是否有 1~n-1 的值 題目是規定 1~n-1 的每個值都要出現一 次 ( 只能出現一次 )

4 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 4 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 4 成果:


Download ppt "按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 Problem E: Jolly Jumpers A sequence of n > 0 integers is called a jolly."

Similar presentations


Ads by Google