아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Möbius

시간 제한2초메모리 제한1024 MB

요약
두 배열이 주어질 때 곱의 뫼비우스 값이 -1, 0, 1인 쌍의 개수를 각각 센다.
난이도

보통10점 중 7점

유형
정수론, 수학, 조합론, 누적 합
정답자
아직 제출이 없습니다

문제

For any positive integer nn, let's define Möbius function μ(n)\mu(n). It has values in −1,0,1\\{-1, 0, 1\\} depending on the factorization of nn into prime factors:

  • μ(x)=1\mu(x) = 1 if xx is a square-free positive integer with an even number of prime factors.
  • μ(x)=−1\mu(x) = -1 if xx is a square-free positive integer with an odd number of prime factors.
  • μ(x)=0\mu(x) = 0 if xx has is divisible by some squared prime factor.

For example, μ(1)=1,μ(2)=−1,μ(6)=1,μ(12)=0\mu(1) = 1, \mu(2) = -1, \mu(6) = 1, \mu(12) = 0.

You are given two arrays aa and bb, consisting of positive integers.

Let k_yk\_y be the number of pairs (i,j),1≤i≤n,1≤j≤m(i, j), 1 \le i \le n, 1 \le j \le m such that μ(a_i⋅b_j)\mu(a\_i\cdot b\_j) is equal to yy.

Your task is to calculate k_−1k\_{-1}, k_0k\_{0} and k_1k\_1.

입력

The first line of input contains two integers n,mn, m (1≤n,m≤2⋅1051 \le n, m \le 2 \cdot 10^5) --- the sizes of arrays aa and bb.

The second line contains nn integers a_ia\_i (1≤a_i≤1061 \le a\_i \le 10^6) separated by spaces.

The third line contains mm integers b_ib\_i (1≤b_i≤1061 \le b\_i \le 10^6) separated by spaces.

출력

Output three integers k_−1,k_0,k_1k\_{-1}, k\_{0}, k\_{1} separated by spaces in a single line, where k_y=∣(i,j):μ(a_i⋅b_j)=y∣k\_y = |\\{(i, j) : \mu(a\_i \cdot b\_j) = y \\}|.

예제1

  1. 예제 1

    입력
    6 4
    1 2 3 4 5 6
    2 3 5 7
    
    예상 출력
    6 9 9