Programming/Python & Data Structures
[Baekjoon/Python3] 1789번 수들의 합
HooNeee
2020. 12. 3. 01:03
[Baekjoon/Python3] 1789번 수들의 합
1789번: 수들의 합
첫째 줄에 자연수 S(1 ≤ S ≤ 4,294,967,295)가 주어진다.
www.acmicpc.net
s = int(input())
n = 1
while n * (n + 1) / 2 <= s:
n += 1
print(n - 1)
s = int(input())
i = 0
sumi = 0
for i in range(1, s + 1):
sumi += i
if sumi + (i + 1) > s:
break
print(i)