#P16234. [蓝桥杯 2026 省 B] 循环右移
[蓝桥杯 2026 省 B] 循环右移
Background
All Lanqiao Cup 2026 provincial contest testdata on this site are created by Luogu and may differ from the official data. They are for learning reference only.
Problem Description
Given three integers . Please compute how many integer arrays of length satisfy the following conditions:
- Each element in array satisfies .
- For any contiguous subarray of , after performing one cyclic right shift operation on it, the new subarray is exactly the same as the original subarray.
Cyclic right shift: For a contiguous subarray of length , , performing one cyclic right shift means transforming it into (i.e., move the last element to the front, and shift the other elements one position to the right in their original order).
Input Format
The first line contains an integer , indicating the number of test cases.
The next lines each contain three integers separated by spaces.
Output Format
For each test case, output one line containing an integer, representing the number of arrays that satisfy the conditions.
3
3 1 2
5 10 10
2 5 3
2
1
0
Hint
Constraints
For of the test cases, , , .
For of the test cases, , , .
Translated by ChatGPT 5