This repository was archived by the owner on Mar 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
[2023-08-18] sumin #113 #133
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
풀이시간: 25분 | ||
|
||
<input> | ||
- 1 ≤ N ≤ 15 | ||
- 0 ≤ r, c < 2N | ||
|
||
<solution> | ||
1. 함수의 정의 | ||
- 2^n x 2^n 배열에서 (r,c)를 방문하는 순서를 반환하는 함수 | ||
|
||
2. base condition | ||
- n = 0일 때, return 0 | ||
|
||
3. 재귀식 | ||
- (r,c)가 1번 사각형일 때, return go(n-1, r, c) | ||
- (r,c)가 2번 사각형일 때, return half*half + go(n-1, r, c-half) | ||
- (r,c)가 3번 사각형일 때, return 2*half*half + go(n-1, r-half, c) | ||
- (r,c)가 4번 사각형일 때, return 3*half*half + go(n-1, r-half, c-half) | ||
|
||
""" | ||
def go(n, r, c): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Go가 뭔가 힘이나고 좋은 함수명인 것 같아서 웃고 갑니다 ㅎㅎ |
||
if n == 0: | ||
return 0 | ||
half = 2 ** (n-1) | ||
if r < half and c < half: # 1번 사각형 | ||
return go(n-1, r, c) | ||
elif r < half and c >= half: # 2번 사각형 | ||
return half * half + go(n-1, r, c-half) | ||
elif r >= half and c < half: # 3번 사각형 | ||
return 2 * half * half + go(n-1, r-1, c) | ||
return 3 * half * half + go(n-1, r-half, c-half) # 4번 사각형 | ||
|
||
|
||
n, r, c = map(int, input().split()) | ||
print(go(n, r, c)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
재귀식이 저랑 같은 것 같아요!! 수민님과 같은 식이 유도된 것 같아 성장한 기분이 듭니다 ㅎㅎ