일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- javascript
- SQL
- ubuntu
- AWS
- 그래프
- SWEA 15612번
- 알고리즘
- 백준 18310번
- 백준 2512번
- HUFS 모각코 캠프
- 명품자바
- 다이나믹프로그래밍
- 모각코
- Python
- 백준 15787번
- react
- 자바
- 백준 1253번
- 다이나믹 프로그래밍
- 백준 1987
- java_programming
- 깃헙
- MySQL
- 그리디
- 백준 16918번
- 백준 1331번
- 머신러닝과 딥러닝
- 백준 3085번
- 백준 17451번
- 백준
Archives
- Today
- Total
차곡차곡
[BOJ/Java] 백준 2210번 - 숫자판 점프 본문
백준 #2210 숫자판 점프
파이썬으로 이전에 풀었던 문제!
[BOJ/Python] 백준 2210번 - 숫자판 점프
백준 #2210 숫자판 점프 2210번: 숫자판 점프 111111, 111112, 111121, 111211, 111212, 112111, 112121, 121111, 121112, 121211, 121212, 211111, 211121, 212111, 212121 이 가능한 경우들이다. www.acmicpc.net import sys sys.setrecursionlimit(1
amor-fati.tistory.com
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
public class Main {
static int[][] map = new int[5][5];
static HashSet<Integer> result = new HashSet<Integer>();
static int[] dx = {0, 0, 1, -1};
static int[] dy = {1, -1, 0, 0};
public static void makeNums(int x, int y, int cnt, double num) {
if (cnt == 6) {
result.add((int)num);
return;
}
for (int i = 0; i < 4; i++) {
int nx = x + dx[i];
int ny = y + dy[i];
if (!(0 <= nx && nx < 5 && 0 <= ny && ny < 5 )) continue;
makeNums(nx, ny, cnt+1, num+map[nx][ny]*(Math.pow(10, cnt)));
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
// 입력 받기
for (int i = 0; i < 5; i++) {
st = new StringTokenizer(br.readLine());
for (int j = 0; j < 5; j++) {
map[i][j] = Integer.parseInt(st.nextToken());
}
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
makeNums(i, j, 0, 0);
}
}
System.out.println(result.size());
} // end of main
} // end of class
'CS > Algorithm' 카테고리의 다른 글
[BOJ/Java] 백준 11286번 - 절댓값 힙 (0) | 2023.08.10 |
---|---|
[BOJ/Java] 백준 5014번 - 스타트링크 (0) | 2023.08.10 |
[BOJ/Java] 백준 14716번 - 현수막 (0) | 2023.08.10 |
[BOJ/Java] 백준 2563번 - 색종이 (0) | 2023.08.09 |
[SWEA/Java] SW Expert Academy 9229번 - 한빈이와 Spot Mart (0) | 2023.08.08 |
Comments