https://s3-us-west-2.amazonaws.com/secure.notion-static.com/8a64e244-8bea-491a-8807-14ecbc76464a/Untitled.png

🔀 코드

start, end = map(int, input().split())
seq = []
n = 1
while n < 50 :
    seq += [n] * n
    n += 1
answer = seq[start-1 : end]
answer = sum(answer)
print(answer)

🤓 해설

구간(시작or끝) = x 라고 하고 구간에 해당하는 수 = n 이라고 하면

n : 1 2 2 3 3 3 4 4 4 4  5  ...
x : 1 2 3 4 5 6 7 8 9 10 11 ...

x 가 1 까지  n 은 1

1+2 = 3 까지 2

1+2+3 = 6 까지 3

1+2+3+4 = 10 까지 4

...

따라서 (n-1)n/2 < x ≤ n(n+1)/2

문제에 주어진 구간(x) 시작~끝이 1 ~ 1,000 이니까

x = 1,000일 때

n^2 - n < 2,000 ≤ n^2 + n

만족하는 n 은 50정도... 라서 while문 범위를 50까지로 했다.

추신: 수열 안 만들고 풀려고 했는데 한 80% 풀다가 포기..ㅠ