Python
1
2
3
4
5
6
7
8
9
|
N = int(input())
summ = 0
i = 0
while summ <= N:
i+=1
summ+=i
print(i-1)
|
cs |
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <iostream>
using namespace std;
int main() {
int i = 0;
long sum = 0;
long N = 0;
scanf("%ld", &N);
while (sum <= N){
i += 1;
sum += i;
}
printf("%d\n", i - 1);
return 0;
}
|
cs |
'Algorithm > BOJ 기초' 카테고리의 다른 글
[백준] 최대공약수와 최소공배수 2609 Python C++ (1934 최소공배수 가능) (0) | 2019.10.04 |
---|---|
[백준] 수들의합 1789 Python C++ (0) | 2019.10.02 |
[백준] 문자열 반복 2675 C++ (0) | 2019.10.02 |
[백준] 화성수학 5355 C++ (0) | 2019.09.30 |
[백준] 스택수열 1874 Python (0) | 2019.09.28 |