๐Ÿ ํŒŒ์ด์ฌ ์ƒ์ดˆ์งœ

[BOJ][Python] ๋ฐฑ์ค€ 28701๋ฒˆ: ์„ธ์ œ๊ณฑ์˜ ํ•ฉ (Bronze V)

์„ ๋‹ฌ 2024. 11. 1. 02:28
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ

์€ํ•˜๋Š” ์ˆ˜์—… ๋•Œ $1$๋ถ€ํ„ฐ $N$๊นŒ์ง€ ์ˆ˜์˜ ํ•ฉ๊ณผ $1$๋ถ€ํ„ฐ $N$๊นŒ์ง€ ์ˆ˜์˜ ์„ธ์ œ๊ณฑ์˜ ํ•ฉ๊ณผ ๊ด€๋ จ๋œ ๋‹ค์Œ ๊ณต์‹์„ ๋ฐฐ์› ์Šต๋‹ˆ๋‹ค.
๋ฏฟ์„ ์ˆ˜ ์—†์—ˆ๋˜ ์€ํ•˜๋Š” ์ง์ ‘ ์ฝ”๋”ฉ์„ ํ•ด์„œ ๊ฒ€์ฆํ•ด ๋ณด๊ธฐ๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค. $1$๋ถ€ํ„ฐ $N$๊นŒ์ง€ ์ˆ˜์˜ ํ•ฉ๊ณผ ๊ทธ ์ˆ˜๋ฅผ ์ œ๊ณฑํ•œ ์ˆ˜, ๋˜ $1$๋ถ€ํ„ฐ $N$๊นŒ์ง€ ์ˆ˜์˜ ์„ธ์ œ๊ณฑ์˜ ํ•ฉ์„ ์ฐจ๋ก€๋Œ€๋กœ ์ถœ๋ ฅํ•˜์„ธ์š”.

์ž…๋ ฅ

์ฒซ ์ค„์— ๋ฌธ์ œ์˜ ์ •์ˆ˜ $N$์ด ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. $(5 \le N \le 100)$

์ถœ๋ ฅ

์„ธ ์ค„์„ ์ถœ๋ ฅํ•˜์„ธ์š”.

 

ํ’€์ด

 

n = int(input())

a = b = c = 0

for i in range(1, n+1):
    a += i
    c += i*i*i
b = a*a

print(a)
print(b)
print(c)
๋ฐ˜์‘ํ˜•