Skip to content

Commit

Permalink
Merge pull request #174 from AlgoLeadMe/15-ljedd2_
Browse files Browse the repository at this point in the history
15 ljedd2
  • Loading branch information
LJEDD2 authored Nov 22, 2024
2 parents baa053d + 6f0214b commit a58de2f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions LJEDD2/2024-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
| 10차시 | 2024.09.11 | 우선순위 큐 | <a href="https://www.acmicpc.net/problem/1715">카드 정렬하기</a> | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/159) |
| 11차시 | 2024.09.18 | 우선순위 큐 | <a href="https://www.acmicpc.net/problem/2075">N번째 큰 수</a> | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/161) |
| 12차시 | 2024.09.21 | 우선순위 큐 | <a href="https://www.acmicpc.net/problem/15903">카드 합체 놀이</a> | [#12](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/164) |
| 13차시 | 2024.09.25 | 플로이드 워셜 | <a href="https://www.acmicpc.net/problem/1058">친구</a> | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/167) |
| 14차시 | 2024.10.02 | 브루트포스 | <a href="https://www.acmicpc.net/problem/11502">세 개의 소수 문제</a> | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/174) |
30 changes: 30 additions & 0 deletions LJEDD2/2024-2/브루트포스/세 개의 소수 문제.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys
input = sys.stdin.readline

# 하나의 소수를 여러 번 더할 수 있다. -> 브루트포스 가능
# 5보다 큰 임의의 홀수로 세 소수의 합이 되는지
def search(n):
for i in arr:
for j in arr:
for k in arr:
if i+j+k == n:
return i, j, k

else: # 안되면 0
return 0

# 에라토스테네스의 체 - 소수 판별
prime = [True] * 1001

for i in range(2,101):
if prime[i]:
for j in range(i*2, 1001, i):
prime[j] = False

# 소수 찾기
arr = [i for i in range(2, 1001) if prime[i] == True]

t = int(input())
for _ in range(t):
n = int(input())
print(*search(n))

0 comments on commit a58de2f

Please sign in to comment.