λ°μν
π€λ¬Έμ ν΄κ²°
-
D3 | μν
π¨ 1λΆν° N κΉμ§ μ«μμ ν©: N * (N + 1) / 2
π¨ 1λΆν° N κ°μ νμμ ν©: N ** 2
π¨ 1λΆν° N κ°μ μ§μμ ν©: N * (N + 1)
π»μμ€ μ½λ
# μΈν
T = int(input())
Ns = [int(input()) for _ in range(T)]
# νμ΄
results = []
for tc in range(T):
n = Ns[tc]
result = []
# μ 체: n(n+1)//2
result.append(n*(n+1)//2)
# νμ: n**2
result.append(n**2)
# μ§μ: n(n+1)
result.append(n*(n+1))
results.append(result)
# κ²°κ³Ό
for tc in range(T):
print(f'#{tc+1}', end=" ")
print(*results[tc])
πλ¬Έμ νμΈ
μΆμ²: SW Expert Academy
λ°μν
'Algorithm Problem > Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[python] SWEA - 3131. 100λ§ μ΄νμ λͺ¨λ μμ (0) | 2020.12.23 |
---|---|
[python] SWEA - 3750. Digit sum (0) | 2020.12.22 |
[python] SWEA - 3376. νλλ° μμ΄ (0) | 2020.12.20 |
[python] SWEA - 3307. μ΅μ₯ μ¦κ° λΆλΆ μμ΄ (0) | 2020.12.19 |
[python] SWEA - 3304. μ΅μ₯ κ³΅ν΅ λΆλΆ μμ΄ (0) | 2020.12.18 |