λ¬Έμ
https://www.acmicpc.net/problem/1699
1699λ²: μ κ³±μμ ν©
μ΄λ€ μμ°μ Nμ κ·Έλ³΄λ€ μκ±°λ κ°μ μ κ³±μλ€μ ν©μΌλ‘ λνλΌ μ μλ€. μλ₯Ό λ€μ΄ 11=32+12+12(3κ° ν)μ΄λ€. μ΄λ° ννλ°©λ²μ μ¬λ¬ κ°μ§κ° λ μ μλλ°, 11μ κ²½μ° 11=22+22+12+12+12(5κ° ν)λ κ°λ₯νλ€
www.acmicpc.net
νμ΄
n = int(input())
dp = [i for i in range (n+1)]
for i in range(1, n+1):
for j in range(1, i):
if (j * j) > i:
break
if dp[i] > dp[i - j * j] + 1:
dp[i] = dp[i - j * j] + 1
print(dp[n])'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
| π© [λ°±μ€] [Python] [Gold5] 1717λ²_μ§ν©μ νν (0) | 2023.03.10 |
|---|---|
| π© [λ°±μ€] [Python] [Silver2] 1406λ²_μλν° (0) | 2023.03.09 |
| π© [λ°±μ€] [Python] [Silver1] 1080λ²_νλ ¬ (0) | 2023.03.01 |
| π© [λ°±μ€] [Python] [Silver2] 11051λ²_μ΄ν κ³μ 2 (0) | 2023.02.27 |
| π© [λ°±μ€] [Python] [Gold4] [μΌμ± SW μλ ν μ€νΈ κΈ°μΆ λ¬Έμ ] 17144λ²_λ―ΈμΈλ¨Όμ§ μλ ! (0) | 2023.02.25 |