[Solution] Distinct Numbers CodeChef Solution
Problem
You are given two positive integers and . You have to perform the following operation exactly times:
- For the current value of , choose any positive integer such that is a divisor of and multiply with .
Formally, such that is a divisor of current value of .
Print the sum of all distinct values of the final you can receive after performing the above operation exactly times. Since the answer can be large, print it modulo .
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case contains two space-separated integers and respectively, the initial number and the number of operations.
Output Format
For each test case, output on a new line the sum of all distinct values of the final you can receive after performing the given operation exactly times. Since the answer can be large, print it modulo .
Explanation:
Test case : is the only divisor of . So, the value remains unchanged after the operations. Thus, there is only one distinct value after operations, which is .
Test case :
- Operation : Initially, has divisors and . Thus, after operation, can be either or .
- Operation : If , the divisors are and which can lead to the final values as and . If , the divisors are and . Thus, the final values can be and .
The distinct values that can be obtained after applying the operation times on are , and .
Test case : The numbers , , and can be obtained after applying the operation time on , and .
No comments:
Post a Comment