Tap here to switch tabs
Problem
Submissions

Problem: Number of Different Subsequences GCDs

med
30 min
Try to solve the Number of Different Subsequences GCDs problem.

Statement

You are given an array nums consisting of positive integers.

The greatest common divisor (GCD) of a sequence of integers is the largest positive integer that divides every integer in the sequence.

Return the total number of distinct greatest common divisors among all nonempty subsequences of nums.

Note: A subsequence of an array is a sequence that can be derived from the array by deleting zero or more elements without changing the relative order of the remaining elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤2imes105\leq 2 imes 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Different Subsequences GCDs

med
30 min
Try to solve the Number of Different Subsequences GCDs problem.

Statement

You are given an array nums consisting of positive integers.

The greatest common divisor (GCD) of a sequence of integers is the largest positive integer that divides every integer in the sequence.

Return the total number of distinct greatest common divisors among all nonempty subsequences of nums.

Note: A subsequence of an array is a sequence that can be derived from the array by deleting zero or more elements without changing the relative order of the remaining elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤2imes105\leq 2 imes 10^5