Skip to content

Commit 96b595a

Browse files
committed
[Gold V] Title: Z, Time: 88 ms, Memory: 108384 KB -BaekjoonHub
1 parent 0b55df1 commit 96b595a

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

백준/Gold/1074. Z/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# [Gold V] Z - 1074
2+
3+
[문제 링크](https://www.acmicpc.net/problem/1074)
4+
5+
### 성능 요약
6+
7+
메모리: 108384 KB, 시간: 88 ms
8+
9+
### 분류
10+
11+
분할 정복, 재귀
12+
13+
### 제출 일자
14+
15+
2025년 3월 11일 19:44:35
16+
17+
### 문제 설명
18+
19+
<p>한수는 크기가 2<sup>N</sup> × 2<sup>N</sup>인 2차원 배열을 Z모양으로 탐색하려고 한다. 예를 들어, 2×2배열을 왼쪽 위칸, 오른쪽 위칸, 왼쪽 아래칸, 오른쪽 아래칸 순서대로 방문하면 Z모양이다.</p>
20+
21+
<p style="text-align:center"><img alt="" src="https://u.acmicpc.net/21c73b56-5a91-43aa-b71f-9b74925c0adc/Screen%20Shot%202020-12-02%20at%208.09.46%20AM.png" style="width: 100px; height: 99px;"></p>
22+
23+
<p>N > 1인 경우, 배열을 크기가 2<sup>N-1</sup> × 2<sup>N-1</sup>로 4등분 한 후에 재귀적으로 순서대로 방문한다.</p>
24+
25+
<p>다음 예는 2<sup>2</sup> × 2<sup>2</sup> 크기의 배열을 방문한 순서이다.</p>
26+
27+
<p style="text-align:center"><img alt="" src="https://u.acmicpc.net/adc7cfae-e84d-4d5c-af8e-ee011f8fff8f/Screen%20Shot%202020-12-02%20at%208.11.17%20AM.png" style="width: 250px; height: 252px;"></p>
28+
29+
<p>N이 주어졌을 때, r행 c열을 몇 번째로 방문하는지 출력하는 프로그램을 작성하시오.</p>
30+
31+
<p>다음은 N=3일 때의 예이다.</p>
32+
33+
<p style="text-align:center"><img alt="" src="https://u.acmicpc.net/d3e84bb7-9424-4764-ad3a-811e7fcbd53f/Screen%20Shot%202020-12-30%20at%2010.50.47%20PM.png" style="width: 533px; height: 535px;"></p>
34+
35+
### 입력
36+
37+
<p>첫째 줄에 정수 N, r, c가 주어진다.</p>
38+
39+
### 출력
40+
41+
<p>r행 c열을 몇 번째로 방문했는지 출력한다.</p>
42+

백준/Gold/1074. Z/Z.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
N, r, c = map(int, input().split())
2+
3+
def recursion(N, r, c):
4+
if N == 0:
5+
return 0
6+
return 2*(r%2)+(c%2) + 4*recursion(N-1, int(r/2), int(c/2))
7+
8+
print(recursion(N, r, c))

0 commit comments

Comments
 (0)