Submit | All submissions | Best solutions | Back to list |
CERI2018J - Euler Totient of factorized integer |
The goal of the problem is to compute the Euler totient function for some integers .
Assume that number , where are prime numbers, and are positive intergers.
You will be given a prime factorization of , you'll have to print .
Input
The first line of the input consist of a single integer number which determines the number of tests.
Each test is on two separate lines.
In each test,
- on the first line, there is two integer numbers , and .
- on the second line, there is integer numbers and , with a prime number.
Constraints
- ;
- ;
- ;
- , a prime number ;
- .
Output
For each test case, print .
Example
Input: 3 0 1000 17,1 2 100 2,1 5,1 7,2 1 1000 3,1 1000000007,1 Output: 16 68 12
Explanation
For the first test case, , and .
For the second test case, , and .
For the third test case, , and .
Added by: | Francky |
Date: | 2018-05-08 |
Time limit: | 1s-3s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |