解题思路:
注意事项:
参考代码:
import math
listB = []
listC = []
listA = list(map(int,input().split()))
n = listA.pop(0)
for i in range(len(listA)-1):#求相邻元素的差的绝对值并存入一listB
listB.append(int(math.fabs(listA[i]-listA[i+1])))
for j in range(1,n):#Jolly判定辅助列表 例如:当 n=4时,listC=[1,2,3]
listC.append(j)
if listC == listB or listC[::-1] == listB:
print("Jolly")
else:
print("Not jolly")
0.0分
1 人评分