#P16065. [CSPro 32] 因子化简
[CSPro 32] 因子化简
Background
Luogu’s testdata is only for non-official communication and is not official testdata. Official judging link: https://www.cspro.org/.
Problem Description
A prime number (also called a “prime”) is a natural number greater than that has no divisors other than and itself.
After learning the concept of prime numbers, student P learned that any positive integer can be uniquely represented as a product of several prime factors. If the positive integer has distinct prime factors , then it can be written as: $n = p_1^{t_1} \times p_2^{t_2} \times \cdots \times p_m^{t_m}$.
Student P believes that the exponent corresponding to each prime factor reflects how important that prime factor is to . Now set a threshold . If the exponent corresponding to some prime factor is less than , then this prime factor is considered unimportant, and the term can be removed by dividing it out from . Otherwise, keep the term . The product of the remaining terms is the simplified value of . If no terms remain, then the simplified value is considered to be .
Write a program to process queries:
- Each query contains two positive integers and , and you need to compute the simplified value of according to the method above.
Input Format
Read data from standard input.
The input consists of lines.
The first line contains a positive integer , indicating the number of queries.
Each of the next lines contains two positive integers and , indicating a query.
Output Format
Write to standard output.
The output consists of lines.
Each line outputs a positive integer, indicating the result for the corresponding query.
3
2155895064 3
2 2
10000000000 10
2238728
1
10000000000
Hint
Sample Explanation
Query 1:
- The prime factor has exponent , and has exponent . After removing these two terms from , the product of the remaining terms is .
Query 2:
- All terms are removed, output .
Query 3:
- All terms are kept, output as is.
Subtasks
of the testdata satisfies: .
of the testdata satisfies: .
All testdata satisfies: and .
Translated by ChatGPT 5