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
- preprocessing
- Inheritance
- 백준
- Operator
- Mac
- Binary Search
- Java
- dbms
- Physical Scheme
- X.org
- BFS
- 리눅스 마스터 1급
- Reference Type
- 자바
- literal
- python
- descriptive statistics
- selenium
- Entity Set
- 셀레니움
- Unity
- External Scheme
- X윈도우
- Polymolphism
- 리눅스
- systemd
- Entity
- OOP
- 리눅스 기초
- Class
Archives
- Today
- Total
Byeol Lo
N15651 - N과 M (3) 본문
import java.io.*;
import java.util.*;
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; i++)
solution(from, to, m - 1, s + i + " ");
}
}
}
'Algorithm > Backtracking' 카테고리의 다른 글
N15652 - N과 M (4) (0) | 2024.06.15 |
---|---|
N15650 - N과 M (2) (0) | 2024.06.15 |
Comments