코딩테스트 소수 만들기 문제풀이
프로그래머스 소수 만들기(level 1) 문제풀이
from itertools import combinations
import math
def solution(nums):
n= 2997
cnt = 0
array = [ True for _ in range(n+1)]
for i in range(2, int(math.sqrt(n)) + 1):
if array[i] == True:
j = 2
while i * j <= n:
array[i*j] = False
j += 1
data = [ sum(i) for i in combinations(nums, 3)]
for d in data:
if array[d] == True:
cnt += 1
return cnt
combinations로 조합을 사용했다 그리고 소수 판별은 에라토네스의 체를 사용했다.
Author And Source
이 문제에 관하여(코딩테스트 소수 만들기 문제풀이), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@kokodak/코딩테스트-소수-만들기-문제풀이저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)