values and a number multiple. Count the non-empty segments (contiguous pieces of the array) whose elements have a least common multiple of exactly multiple.
The LCM of a set of numbers is the smallest positive integer divisible by each of them. Segments with different bounds count separately.values=[2, 3, 4, 6, 5], multiple=12 → 5
The LCM is 12 for [2, 3, 4], [3, 4], [3, 4, 6], [2, 3, 4, 6] and also [4, 6]. Any segment with 5 in it has an LCM divisible by 5.
values=[5], multiple=10 → 0
The only segment, [5], has LCM 5, not 10.
values=[1, 3, 1, 3], multiple=3 → 8
values) ≤ 1000values[i] ≤ 1000multiple ≤ 1000values=[2, 3, 4, 6, 5], multiple=12
5
Run checks the first 3 tests in your browser. Submit checks all 108 tests on the server, hidden ones included.