QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 256 MB Total points: 100

#18180. 莫比乌斯

Statistics

对于任意正整数 $n$,我们定义莫比乌斯函数 $\mu(n)$。根据 $n$ 的质因子分解,它的取值为 $\{-1, 0, 1\}$ 之一:

  • 如果 $x$ 是一个含有偶数个质因子的无平方因子正整数,则 $\mu(x) = 1$。
  • 如果 $x$ 是一个含有奇数个质因子的无平方因子正整数,则 $\mu(x) = -1$。
  • 如果 $x$ 能被某个素数的平方整除,则 $\mu(x) = 0$。

例如,$\mu(1) = 1$,$\mu(2) = -1$,$\mu(6) = 1$,$\mu(12) = 0$。

给你两个由正整数组成的数组 $a$ 和 $b$。

设 $k_y$ 为满足 $\mu(a_i \cdot b_j) = y$ 的二元组 $(i, j)$($1 \le i \le n$,$1 \le j \le m$)的数量。

你的任务是计算 $k_{-1}$,$k_0$ 和 $k_1$。

输入格式

第一行输入包含两个整数 $n, m$($1 \le n, m \le 2 \cdot 10^5$)—— 数组 $a$ 和 $b$ 的大小。

第二行包含 $n$ 个空格分隔的整数 $a_i$($1 \le a_i \le 10^6$)。

第三行包含 $m$ 个空格分隔的整数 $b_i$($1 \le b_i \le 10^6$)。

输出格式

在单行中输出三个由空格分隔的整数 $k_{-1}, k_0, k_1$,其中 $k_y = |\{(i, j) : \mu(a_i \cdot b_j) = y\}|$。

样例

输入样例 1

6 4
1 2 3 4 5 6
2 3 5 7

输出样例 1

6 9 9

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.