λ°μν
π€λ¬Έμ ν΄κ²°
-
D3 | μμ, μμ νμ
π¨ 미리 μμλ₯Ό ꡬν΄λλλ€.
π¨ 3μ€ ν¬λ¬ΈμΌλ‘ μμ 3κ°λ₯Ό λν΄μ N μ΄ λμ€λ©΄ True
π»μμ€ μ½λ
prime = []
for i in range(2, 1000):
for j in range(2, i):
if i % j == 0:
break
else:
prime.append(i)
for tc in range(int(input())):
N = int(input())
M = len(prime)
cnt = 0
for i in range(M):
if prime[i] > N:
break
for j in range(i, M):
if prime[j] > N:
break
for k in range(j, M):
if prime[k] > N:
break
if prime[i] + prime[j] + prime[k] == N:
cnt += 1
print(f'#{tc + 1} {cnt}')
πλ¬Έμ νμΈ
μΆμ²: SW Expert Academy
λ°μν
'Algorithm Problem > Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[python] λ°±μ€ - 2573. λΉμ° (0) | 2020.11.26 |
---|---|
[python] λ°±μ€ - 2493. ν (0) | 2020.11.25 |
[python] λ°±μ€ - 13458. μν κ°λ (μΌμ± SW μλ ν μ€νΈ κΈ°μΆ λ¬Έμ ) (0) | 2020.11.23 |
[python] SWEA - 6057. κ·Έλνμ μΌκ°ν (0) | 2020.11.22 |
[python] SWEA - 6692. λ€μμ΄μ μκΈ μμ (0) | 2020.11.20 |