Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 자바스크립트
- padEnd
- 백준3052번
- javascropt
- 웹개발종합반
- dateobject
- JOIN
- node.js
- padStart
- 프로그래머스
- sanitize-html
- gethours
- 시간보여주기
- JavaScript#조건문#conditional
- classList
- appendChild
- localstorage
- LEFTJOIN
- java기초
- Database
- classname
- Login
- JavaScript
- 스파르타코딩클럽
- 스택큐
- 올바른괄호
- function
- MySQL
- getMinutes
- SQL
Archives
- Today
- Total
just do it
수들의합5/백준2018번/투포인터(do it) 본문
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int sum= 1;
int count = 1;
int start_index=1;
int end_index=1;
while(start_index<=N/2) { //while(end_index !=N)
if(N>sum) {
end_index++;
sum=sum+end_index;
}else if(N==sum) {
end_index++;
sum=sum+end_index;
count++;
}else if(N<sum) {
sum=sum-start_index;
start_index++;
}
}System.out.println(count);
}
}
|
cs |
'자료구조&알고리즘 > 코딩테스트' 카테고리의 다른 글
백준 12891번/DNA비밀번호/java (0) | 2022.09.26 |
---|---|
좋다/백준1253번/투포인터(java) (1) | 2022.09.24 |
백준11660/구간합구하기5 (0) | 2022.09.17 |
구간 합 구하기/백준 11659번(java) (0) | 2022.09.15 |
평균 구하기/백준1546번 (0) | 2022.09.13 |