[20250510] BOJ / G4 / 행렬 제곱 #331
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.
🧷 문제 링크
https://www.acmicpc.net/problem/10830
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
행렬 제곱을 구하기
🔍 풀이 방법
제곱하는 크기가 매우 크기 때문에 분할하여 구해야함. a^100 = (a*a)^50을 이용
⏳ 회고
a의 1제곱을 반환할 때, 입력 그대로 반환했는데 이러면 이후 내부 연산에서 꼬일 수 있어 복사해야했고 또, 첫 입력이 1000이 들어오면 모듈러 연산이 적용되지 않아 0이 나와야하지만 1000이 나오는 예외가 생긴다. 항상 모듈러연산이 모든 연산의 과정에 적용되고 있는지 확인하자.