Tap here to switch tabs
Problem
Submissions

Problem: Maximum GCD-Sum of a Subarray

Try to solve the Maximum GCD-Sum of a Subarray problem.

Statement

Given an array of integers nums and an integer k, determine the maximum GCD sum among all subarrays with a length of at least k.

The GCD sum of a subarray is defined as the greatest common divisor of all elements in that subarray multiplied by the sum of all elements in that subarray.

Return the maximum GCD sum that can be obtained.

Note: A subarray is a contiguous sequence of elements within an array.

Constraints:

  • n ==== nums.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum GCD-Sum of a Subarray

Try to solve the Maximum GCD-Sum of a Subarray problem.

Statement

Given an array of integers nums and an integer k, determine the maximum GCD sum among all subarrays with a length of at least k.

The GCD sum of a subarray is defined as the greatest common divisor of all elements in that subarray multiplied by the sum of all elements in that subarray.

Return the maximum GCD sum that can be obtained.

Note: A subarray is a contiguous sequence of elements within an array.

Constraints:

  • n ==== nums.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq n