#P3172. [CQOI2015] 选数
[CQOI2015] 选数
Description
We know that selecting integers from the interval (where and are integers) yields schemes. Little z is curious about the pattern of the greatest common divisor of the numbers selected in this way. He decides to compute the greatest common divisor of the integers for every scheme for further study. However, he soon finds the workload too large, so he asks for your help. Your task is simple: Little z will give you an integer , and you need to answer how many selection schemes have their greatest common divisor exactly equal to .
Since the number of schemes can be large, you only need to output the remainder modulo .
Input Format
The input consists of one line containing four space-separated positive integers, in order: .
Output Format
Output a single integer, which is the remainder of the required count modulo .
2 2 2 4
3
Hint
Sample 1 Explanation.
All possible selection schemes: $(2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4), (4, 2), (4, 3), (4, 4)$.
Among them, those with greatest common divisor equal to are only groups: .
Constraints.
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号