Distinct Subarray GCDs
Time limit5sMemory limit256 MB
Count the distinct GCD values taken over all contiguous subarrays for each test case.
- Level
Medium5 of 10
- Topics
- Number theory, Dynamic programming, Hash map
- Solved
- No attempts yet
Problem
For a sequence of length , define as the GCD of through (indices, not values). Count how many distinct values can take.
Input
Multiple test cases. Each starts with n$$(1 \le n \le 100000), then lines each with an element a$$(1 \le a \le 100). Input ends when .
Output
For each test case, print the number of distinct GCD values on one line.