Sum of Squares of Special Elements
You are given a 1-indexed integer array nums of length n.
An element nums[i] of nums is called special if i divides n, i.e. n % i == 0.
Return the sum of the squares of all special elements of nums.
Example 1
Input
nums = [1,2,3,4]Output
21There are exactly 3 special elements in nums: nums[1], nums[2], and nums[4], so the sum of their squares is 1 * 1 + 2 * 2 + 4 * 4 = 21.
Example 2
Input
nums = [2,7,1,19,18,3]Output
63There are exactly 4 special elements in nums: nums[1], nums[2], nums[3], and nums[6], so the sum of their squares is 2 * 2 + 7 * 7 + 1 * 1 + 3 * 3 = 63.
Constraints
- 1 <= nums.length == n <= 50
- 1 <= nums[i] <= 50