Python
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 |
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 기초' 카테고리의 다른 글
[백준] 주사위 세개 2480 Python C++ (0) | 2019.10.04 |
---|---|
[백준] 최대공약수와 최소공배수 2609 Python C++ (1934 최소공배수 가능) (0) | 2019.10.04 |
[백준] 소인수분해 11653 Python C++ (0) | 2019.10.02 |
[백준] 문자열 반복 2675 C++ (0) | 2019.10.02 |
[백준] 화성수학 5355 C++ (0) | 2019.09.30 |