Skip to content

Commit

Permalink
BOJ: 11729 풀이
Browse files Browse the repository at this point in the history
Closed #195
  • Loading branch information
suhyunsim committed Jan 17, 2022
1 parent a1468e8 commit e98d3f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ Closed #24
- [x] [BOJ - 14501. 퇴사](https://github.com/suhyunsim/Algorithm_Practice/issues/73)
- [ ] [BOJ - 6603. 로또](https://github.com/suhyunsim/Algorithm_Practice/issues/83)
- [ ] [PG - 타겟 넘버](https://github.com/suhyunsim/Algorithm_Practice/issues/121)
- [ ] [BOJ - 1629. 곱셈](https://github.com/suhyunsim/Algorithm_Practice/issues/)

- [ ] [BOJ - 1629. 곱셈](https://github.com/suhyunsim/Algorithm_Practice/issues/194)
- [ ] [BOJ - 11729. 하노이 탑 이동 순서](https://github.com/suhyunsim/Algorithm_Practice/issues/195)

## 탐욕
- [x] [PG - 체육복](https://github.com/suhyunsim/Algorithm_Practice/issues/95)
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/poogle/BOJ/Q11729/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main.java.com.poogle.BOJ.Q11729;

import java.util.Scanner;

public class Main {
static StringBuilder sb = new StringBuilder();

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sb.append((1 << n) - 1).append('\n');
calculate(1, 3, n);
System.out.println(sb);
}

private static void calculate(int a, int b, int n) {
if (n == 1) {
sb.append(a).append(" ").append(b).append("\n");
return;
}
calculate(a, 6 - a - b, n - 1);
sb.append(a).append(" ").append(b).append("\n");
calculate(6 - a - b, b, n - 1);
}
}

0 comments on commit e98d3f6

Please sign in to comment.