07-01 02:16
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- External Scheme
- OOP
- 리눅스
- python
- Unity
- Entity Set
- descriptive statistics
- Operator
- Polymolphism
- Mac
- Inheritance
- preprocessing
- X윈도우
- systemd
- Java
- Class
- X.org
- 자바
- 리눅스 기초
- dbms
- Physical Scheme
- Entity
- Reference Type
- literal
- BFS
- 리눅스 마스터 1급
- 백준
- Binary Search
- selenium
- 셀레니움
Archives
- Today
- Total
Byeol Lo
N15650 - N과 M (2) 본문
import java.util.*;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
public class Main {
final static BufferedWriter BW = new BufferedWriter(new OutputStreamWriter(System.out));
final static StringBuffer sb = new StringBuffer();
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) throws IOException {
solution(1, sc.nextInt(), sc.nextInt(), "");
BW.write(sb.toString());
BW.close();
}
public static void solution(int from, int to, int m, String s) {
if (m == 1) {
for (int i = from; i <= to; i++)
sb.append(s + i + "\n");
} else {
for (int i = from; i <= to - m + 1; i++)
solution(i + 1, to, m - 1, s + i + " ");
}
}
}
'Algorithm > Backtracking' 카테고리의 다른 글
N15652 - N과 M (4) (0) | 2024.06.15 |
---|---|
N15651 - N과 M (3) (0) | 2024.06.15 |
Comments