此代码目前仅在鼠标悬停和鼠标移出事件期间加载。我想在页面加载时执行。我已经尝试修改事件以阅读...但它只是停止一起运行。有什么建议吗?另外,有关如何添加复选框以禁用该功能的任何建议吗?
global a
a = list(map(int , input().split()))
global DP
global neg_
global sum_seq
sum_seq = [0]*len(a)
def solve(i):
k = 1
a1 = []
b1 = []
while i + 1:
if i == len(a) - 1 or i == len(a) - 2:
if i == len(a) - 1:
a1.append(a[i])
sum_seq[i] = a[i]
if i == len(a) - 2:
if a[i] > sum_seq[i + 1]:
b1.append(a[i])
sum_seq[i] = a[i]
else:
b1.append(a[i+1])
sum_seq[i] = sum_seq[i+1]
else:
if k % 2:
if sum_seq[i + 1] < sum_seq[i+2] + a[i]:
a1.append(a[i])
sum_seq[i] = sum_seq[i+2] + a[i]
k += 1
else:
sum_seq[i] = sum_seq[i+1]
a1.clear()
a1 = b1[:]
k += 1
else:
if sum_seq[i+1] < sum_seq[i+2] + a[i]:
b1.append(a[i])
sum_seq[i] = sum_seq[i+2] + a[i]
k += 1
else:
sum_seq[i] = sum_seq[i+1]
b1.clear()
b1 = a1[:]
k += 1
i -= 1
print(*a1)
print(*b1)
print(sum(a1))
print(sum(b1))
solve(len(a) - 1)
答案 0 :(得分:0)
使用以下内容:
jQuery(window).on("load", function(){
sparkle.over();
});