CCF 202112-1 序列查询(python)

观察式子发现规律

n, N = map(int, input().split())
num = list(map(int, input().split()))
sum1 = 0
for i in range(0, n-1):
    sum1 += (num[i+1] - num[i]) * (i+1)
sum1 += (N-num[n-1])*n
print(sum1)

posted @ 2022-08-09 16:17  白缺  阅读(38)  评论(0编辑  收藏  举报