← All problemsSign in

Counting LCM Arrays

CSESAdditional Problems IOpen on judge ↗

Given two integers n and k, your task is to count the number of arrays a_1, a_2,\dots, a_n of positive integers where \operatorname{lcm}(a_i, a_{i+1}) = k for all 1 \le i < n. Input The first line has an integer t: the number of test cases. The next t lines have two integers n and k: the length of the array and the value of lcm. Output Print t integers: the answer to each test case modulo 10^

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start