PS/BOJ
[백준] 수들의 합
RUBY_루비
2020. 9. 26. 23:59
출처:: www.acmicpc.net/problem/1789
분류::
1. 문제 이해 및 해결과정
2. 풀이방법
1.
#수들의 합
#https://www.acmicpc.net/problem/1789
import sys
sys.stdin = open("input.txt","r")
n=int(input())
#x(x+1)/2 = n
x=1
while(x*(x+1)/2 <=n):
x+=1
print(x-1)
2.
#수들의 합
#https://www.acmicpc.net/problem/1789
import sys
sys.stdin = open("input.txt","r")
n=int(input())
#x(x+1)/2 = n
num,sum=1,0
cnt=0
while True:
sum+=num
cnt+=1
if sum>n:
break
num+=1
print(cnt-1)
3. 오답원인
4. 알게된 점