【蓝桥杯每日一题】求和——前缀和

给定 n n n 个整数 a 1 , a 2 , … , a n a_1, a_2, \ldots, a_n a1,a2,,an,求它们两两相乘再相加的和,即:

S = a 1 ⋅ a 2 + a 1 ⋅ a 3 + … + a 1 ⋅ a n + a 2 ⋅ a 3 + … + a n − 2 ⋅ a n − 1 + a n − 2 ⋅ a n + a n − 1 ⋅ a n S = a_1 \cdot a_2 + a_1 \cdot a_3 + \ldots + a_1 \cdot a_n + a_2 \cdot a_3 + \ldots + a_{n-2} \cdot a_{n-1} + a_{n-2} \cdot a_n + a_{n-1} \cdot a_n S=a1a2+a1a3++a1an+a2a3++an2an1+an2an+an1an

上一篇:Ubuntu搭建ES8集群+加密通讯+https访问