728x90
https://www.acmicpc.net/problem/1789
1789번: 수들의 합
첫째 줄에 자연수 S(1 ≤ S ≤ 4,294,967,295)가 주어진다.
www.acmicpc.net
s = int(input())
minus = 1
cnt = 0
while True:
if s == 1:
cnt=1
break
if s < 0:
cnt-=1
break
s -= minus
minus +=1
cnt += 1
print(cnt)
# 여전히 헷갈린다..
반응형
'전.py' 카테고리의 다른 글
클래스 (0) | 2020.12.24 |
---|---|
백준 1934 최소공배수 (0) | 2020.12.24 |
백준 11653 소인수분해 (0) | 2020.12.24 |
파일 읽고 쓰기 (0) | 2020.12.24 |
함수 **args 인자 사용 (0) | 2020.12.24 |