[Gold I] Title: 제곱 ㄴㄴ 수, Time: 1084 ms, Memory: 42352 KB -BaekjoonHub

This commit is contained in:
SSUM
2025-02-20 09:42:26 +09:00
parent 44c68b67e0
commit a60e88d79b
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# [Gold I] 제곱 ㄴㄴ 수 - 1016
[문제 링크](https://www.acmicpc.net/problem/1016)
### 성능 요약
메모리: 42352 KB, 시간: 1084 ms
### 분류
수학, 정수론, 소수 판정, 에라토스테네스의 체
### 제출 일자
2025년 2월 20일 09:40:53
### 문제 설명
<p>어떤 정수 X가 1보다 큰 제곱수로 나누어 떨어지지 않을 때, 그 수를 제곱ㄴㄴ수라고 한다. 제곱수는 정수의 제곱이다. min과 max가 주어지면, min보다 크거나 같고, max보다 작거나 같은 제곱ㄴㄴ수가 몇 개 있는지 출력한다.</p>
### 입력
<p>첫째 줄에 두 정수 min과 max가 주어진다.</p>
### 출력
<p>첫째 줄에 min보다 크거나 같고, max보다 작거나 같은 제곱ㄴㄴ수의 개수를 출력한다.</p>

View File

@@ -0,0 +1,23 @@
import math
import sys
input = sys.stdin.readline
min, max = map(int, input().split())
arr = [False] * (max-min+1)
for i in range(2, int(math.sqrt(max)+1)):
pow = i * i
start_index = int(min / pow) # 제곱수가 아닌 수 -> 제곱수는 무언가를 곱해서 만드는 수 ? 인걸로 이해했는데
if min % pow!=0:
start_index += 1
for j in range(start_index, int(max/pow)+1):
arr[int((j*pow) - min)] = True
count = 0
for i in range(0, max-min+1):
if arr[i] == False:
count += 1
print(count)