迴文鏈表
d = list(map(int, input().split()))
if d == d[::-1]:
print("True")
else:
print("False")
複製代碼
吃薯片
d = list(map(int, input().split()))
def eat(n, nums):
m = len(nums)
dp = [[0] * m for j in range(m)]
for i in range(m):
dp[i][i] = nums[i]
for i in reversed(range(0, n)):
for j in range(i + 1, m):
dp[i][j] = sum(nums[i:j+1]) - min(dp[i+1][j], dp[i][j-1])
total_sum = sum(nums[0:n])
return dp[0][n-1], total_sum - dp[0][-1]
xiaomi, dami = eat(len(d), d)
if xiaomi>=dami:
print("Yes")
else:
print("No")
複製代碼