From bab8f2a984e6160ff61cb4e4d42c46829fba11e5 Mon Sep 17 00:00:00 2001 From: SSUM <116950962+ssum21@users.noreply.github.com> Date: Mon, 24 Mar 2025 20:49:33 +0900 Subject: [PATCH] [Gold V] Title: Z, Time: 44 ms, Memory: 32412 KB -BaekjoonHub --- 백준/Gold/1074. Z/README.md | 42 +++++++++++++++++++++++++++++++++++++ 백준/Gold/1074. Z/Z.py | 27 ++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 백준/Gold/1074. Z/README.md create mode 100644 백준/Gold/1074. Z/Z.py diff --git a/백준/Gold/1074. Z/README.md b/백준/Gold/1074. Z/README.md new file mode 100644 index 0000000..e1b83cf --- /dev/null +++ b/백준/Gold/1074. Z/README.md @@ -0,0 +1,42 @@ +# [Gold V] Z - 1074 + +[문제 링크](https://www.acmicpc.net/problem/1074) + +### 성능 요약 + +메모리: 32412 KB, 시간: 44 ms + +### 분류 + +분할 정복, 재귀 + +### 제출 일자 + +2025년 3월 24일 20:49:18 + +### 문제 설명 + +
한수는 크기가 2N × 2N인 2차원 배열을 Z모양으로 탐색하려고 한다. 예를 들어, 2×2배열을 왼쪽 위칸, 오른쪽 위칸, 왼쪽 아래칸, 오른쪽 아래칸 순서대로 방문하면 Z모양이다.
+ +
N > 1인 경우, 배열을 크기가 2N-1 × 2N-1로 4등분 한 후에 재귀적으로 순서대로 방문한다.
+ +다음 예는 22 × 22 크기의 배열을 방문한 순서이다.
+ +N이 주어졌을 때, r행 c열을 몇 번째로 방문하는지 출력하는 프로그램을 작성하시오.
+ +다음은 N=3일 때의 예이다.
+ +첫째 줄에 정수 N, r, c가 주어진다.
+ +### 출력 + +r행 c열을 몇 번째로 방문했는지 출력한다.
+ diff --git a/백준/Gold/1074. Z/Z.py b/백준/Gold/1074. Z/Z.py new file mode 100644 index 0000000..ed48346 --- /dev/null +++ b/백준/Gold/1074. Z/Z.py @@ -0,0 +1,27 @@ +import sys + +input = sys.stdin.readline +sys.setrecursionlimit(10**6) + +N, r, c = map(int, input().split()) + +def squared(n, r, c, tot): + next_right, next_height = 2** n, 2** n + if(n==1 and r==0 and c==0): + return tot + elif(n==1 and r==0 and c==1): + return tot+1 + elif(n==1 and r==1 and c==0): + return tot+2 + elif(n==1 and r==1 and c==1): + return tot+3 + if (r