題目連結

https://zerojudge.tw/ShowProblem?problemid=a111

https://onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=3301

參考文章

X

本題要點

在紙上畫出 11, 22, 33, 44 就會發現他有規律

1*1 = 1

2*2 = 1 + 4

3*3 = 1 + 4 + 9

4*4 = 1 + 4 + 9 + 16

有兩種方法

一種是用 for 迴圈 for i in range(1, i+1): 這樣 然後把每一項平方相加

一種是用數學公式解 高三會學 Σ

截圖 2024-06-16 中午12.25.26.png

Untitled

長這樣 他有個公式 [input * (input+1) * (input * 2+1)] / 6

參考解答

解一: