#P1072. [NOIP 2009 提高组] Hankson 的趣味题
[NOIP 2009 提高组] Hankson 的趣味题
Description
Dr. Hanks is a renowned expert in BT (Bio-Tech, 生物技术). His son is named Hankson. Now, just home from school, Hankson is thinking about an interesting problem.
Today in class, the teacher explained how to find the greatest common divisor and least common multiple of two positive integers and . Now that Hankson believes he has mastered these topics, he starts considering an "inverse problem" to problems like "finding a common divisor" and "finding a common multiple". The problem is as follows: given positive integers , let an unknown positive integer satisfy:
- The greatest common divisor of and is .
- The least common multiple of and is .
Hankson's "inverse problem" is to find all positive integers that satisfy the conditions. After a little thought, he realizes such are not necessarily unique and may even not exist. Therefore, he turns to counting how many satisfy the conditions. Please help him write a program to solve this problem.
Input Format
The first line contains a positive integer , indicating there are sets of input. Each of the next lines contains one set of input: four positive integers , separated by single spaces. It is guaranteed that is divisible by , and is divisible by .
Output Format
Output lines. For each set of input, output a single integer on one line.
For each set: if no such exists, print ; if such exist, print the number of that satisfy the conditions.
2
41 1 96 288
95 1 37 1776
6
2
Hint
- [Sample Explanation]
- For the first set, can be , for a total of .
- For the second set, can be , for a total of .
- [Constraints]
- For of the testdata, it is guaranteed that and .
- For of the testdata, it is guaranteed that and .
Translated by ChatGPT 5
京公网安备 11011102002149号