Möbius
Time limit2sMemory limit1024 MB
Given arrays a and b, count the pairs (a_i, b_j) by the value of the Möbius function of their product, for -1, 0, and 1.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Combinatorics
- Solved
- No attempts yet
Statement
For any positive integer , the Möbius function is defined. Its value is in , depending on the prime factorization of .
- If is a square-free positive integer with an even number of prime factors, then .
- If is a square-free positive integer with an odd number of prime factors, then .
- If is divisible by the square of some prime, then .
For example, , , , and .
You are given two arrays and of positive integers.
Let be the number of pairs with and such that .
Compute , , and .
Input
The first line contains two integers and (), the sizes of arrays and .
The second line contains integers () separated by spaces.
The third line contains integers () separated by spaces.
Output
Print three integers , , and separated by spaces on a single line.