(Python/Python) 백준 #14929 짜증나 (SIB)

문제


기입

n 및 $x_i$주어진 것인가? n은 100,000 미만이고 $x_i$100보다 작거나 같은 곱셈 값을 갖는 정수 di입니다.

누르다

위에서 요청한 내용을 요청하기만 하면 됩니다.

암호

n = int(input())
arr = list(map(int, input().split()))
res = 0
accumulate = (arr(0))
for i in range(1, n):
    accumulate.append(accumulate(i-1) + arr(i))
for j in range(n):
    res += arr(j) * (accumulate(n-1) - accumulate(j))
print(res)

위 식은 다음과 같이 표현할 수 있습니다.


따라서 위의 코드와 같이 누적 합을 구할 수 있습니다.