π€/λ°±μ€
λ°±μ€ 9020: 골λλ°νμ μΆμΈ‘ (Python)
sssbin
2021. 9. 1. 15:26
https://www.acmicpc.net/problem/9020
9020λ²: 골λλ°νμ μΆμΈ‘
1λ³΄λ€ ν° μμ°μ μ€μμ 1κ³Ό μκΈ° μμ μ μ μΈν μ½μκ° μλ μμ°μλ₯Ό μμλΌκ³ νλ€. μλ₯Ό λ€μ΄, 5λ 1κ³Ό 5λ₯Ό μ μΈν μ½μκ° μκΈ° λλ¬Έμ μμμ΄λ€. νμ§λ§, 6μ 6 = 2 × 3 μ΄κΈ° λλ¬Έμ μμκ° μ
www.acmicpc.net
μ²μ μ½λ - λ μκ° μ΄κ³Ό,,,,,,,,
μ«μλ₯Ό μ²μλΆν° λ£μ΄μ μ°¨μ΄κ°μ λΉκ΅νμλ€
num = []
for i in range(2, 10000):
cnt = 0
for p in range(2, int(i**0.5)+1):
if i % p == 0:
cnt += 1
break
if cnt == 0:
num.append(i)
t = int(input())
for i in range(t):
n = int(input())
d = n
for j in num:
if j in range(n//2+1):
if n - j in num:
if n - j - j < d:
d = n - j - j
else:
break
print((n-d)//2,n-(n-d)//2)
μ΄λ²μ κ·Έλμ μμ μ€κ°κ°λΆν° λ£μλ€
κ·Έλ¬λ©΄ μ°¨μ΄κ° κ°μ₯ μμ κ²λΆν° μμνλκΉ μ°¨μ΄κ°μ λΉκ΅ν νμκ° μλ€!
num = []
for i in range(2, 10000):
cnt = 0
for p in range(2, int(i**0.5)+1):
if i % p == 0:
cnt += 1
break
if cnt == 0:
num.append(i)
t = int(input())
for i in range(t):
n = int(input())
a = n//2
b = a
while a > 0:
if a in num and b in num:
print(a, b)
break
else:
a -= 1
b += 1