[Gold V] Title: 거의 소수, Time: 5472 ms, Memory: 432152 KB -BaekjoonHub

This commit is contained in:
SSUM
2025-02-16 00:38:15 +09:00
parent 3ffa18035f
commit 5cac6eb48b
2 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
# [Gold V] 거의 소수 - 1456
[문제 링크](https://www.acmicpc.net/problem/1456)
### 성능 요약
메모리: 432152 KB, 시간: 5472 ms
### 분류
수학, 정수론, 소수 판정, 에라토스테네스의 체
### 제출 일자
2025년 2월 16일 00:35:49
### 문제 설명
<p>어떤 수가 소수의 N제곱(N ≥ 2) 꼴일 때, 그 수를 거의 소수라고 한다.</p>
<p>두 정수 A와 B가 주어지면, A보다 크거나 같고, B보다 작거나 같은 거의 소수가 몇 개인지 출력한다.</p>
### 입력
<p>첫째 줄에 왼쪽 범위 A와 오른쪽 범위 B가 공백 한 칸을 사이에 두고 주어진다.</p>
### 출력
<p>첫째 줄에 총 몇 개가 있는지 출력한다.</p>

View File

@@ -0,0 +1,28 @@
import sys
import math
input = sys.stdin.readline
Min, Max = map(int, input().split())
A = [0]*10000001
for i in range(len(A)):
A[i] = i
for i in range(2, int(math.sqrt(len(A)))+1):
if A[i]==0:
continue
for j in range(i+i, len(A), i):
A[j] = 0
count = 0
for i in range(2, 10000001):
if A[i]!= 0:
temp = A[i]
while A[i] <= Max / temp:
if A[i] >= Min / temp:
count +=1
temp = temp * A[i]
print(count)