Submit | All submissions | Best solutions | Back to list |
TGCD2 - Trending GCD (Hard) |
This problem is a harder version of TRENDGCD.
Given and , compute
where and is the Möbius function, that is, if is square-free and otherwise. Especially, .
Input
The first line contains an integer , indicating the number of test cases.
Each of the next lines contains two positive integers and .
Output
For each test case, print modulo in a single line.
Example
Input: 5
42 18
35 1
20 25
123456789 987654321
233333333333 233333333333 Output: 306395
630
128819
897063534
355737203
Constraints
There are 6 test files.
Test #0: , .
Test #1: , .
Test #2: , .
Test #3: , .
Test #4: , .
Test #5: , .
@Speed Addicts: My solution runs in 20.76s (total time). (approx 3.46s per file)
WARNING: The time limit may be somewhat strict.
Added by: | liouzhou_101 |
Date: | 2019-03-27 |
Time limit: | 20s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | TRENDGCD |