[20250910] BOJ / G1 / 제곱 ㄴㄴ수 / 이강현 #859
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/1016
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
min과 max 사이의 값에서 1보다 큰 제곱수로 나누어지지 않는 수의 개수를 출력.
🔍 풀이 방법
set
min이 1조까지고 max가 min과 최대 100만 차이라 대략 고려해야하는 제곱수가 100만개정도 됌. 그래서 다 구해놓고
제곱수 하나씩 순회하면서 제곱수 * i가 min에서 max 사이에 있는 경우 set에 넣음.
그리고 max - min +1 에서 set의 크기를 빼주면 됨.
제곱수로 늘려가며 나누니까 시그마 1 / i^2 이면 파이/6으로 수렴하니까
시간 복잡도가 O(N)이다.
⏳ 회고
제곱수가 아니어도 O(NlogN) 이다.