1주차 - 숫자 정사각형(1051) #12
Merged
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.
** 📘 풀이한 문제 **
BOJ 1051번 (https://www.acmicpc.net/problem/4796)
** ⭐ 문제에서 주로 사용한 알고리즘 **
완전탐색
** 📜 대략적인 코드 설명 **
가로 길이와 세로 길이 중 짧은 것을 찾아낸 뒤, 그 값에서 1씩 감소시켜 가며 꼭짓점이 같은 경우를 찾아내면 됩니다.
해당 길이에서 가장 큰 넓이를 반복적으로 구해야 하므로 함수를 만들었습니다.
길이보다 1 작은 값을 함수 인자로 넘겼고, 그렇기에 넓이를 구할 때에 +1해 준 뒤 제곱하여 반환하였습니다.
해당 인자에서 찾아내지 못한 경우 -1을 반환하였고 메인 함수에서 값이 -1인 여부를 판단하여 더 진행할지 아니면 그칠지 판단하게끔 하였습니다.
PS) github desktop을 이용하여 pull, push를 진행중인데 풀 리퀘스트 시에 문제가 발생하게 되네요. 직접 홈페이지를 이용하여 업로드 하는 방식을 공부해 보겠습니다.
PS2) 라벨 권한도 주시면 감사하겠습니다.