今日份感想:今天好忙,偷闲做了几题:)
题源都来自洛谷
目录
P1152 欢乐的跳
看了好几遍题目才明白它的意思-.-
我的想法是另开一个list来记录[1,n-1]哪些整数出现过,出现过mark 1,最后统计list中1的数量,要是满足n-1个,即为“Jolly”
AC代码:
nums = input().split()
n = int(nums[0])
mark = list()
for i in range(n):
mark.append("0")
mark[i] = int(mark[i])
for i in range(1,n):
t = int(nums[i])-int(nums[i+1])
cnd = abs(t)
if cnd >= 1 and cnd <= (n-1):
mark[cnd-1] = 1
if mark.count(1) == n-1:
print("Jolly")
else:
print("Not jolly")