#P4068. [SDOI2016] 数字配对

    ID: 2975 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>贪心2016各省省选网络流山东二分图最大流素数判断,质数,筛法

[SDOI2016] 数字配对

Description

There are nn types of numbers. For the ii-th type, the number is aia_i, there are bib_i copies of it, and its weight is cic_i.

If two numbers aia_i and aja_j satisfy that aia_i is a multiple of aja_j, and ai/aja_i / a_j is a prime number, then these two numbers can be paired, gaining a value of ci×cjc_i \times c_j.

Each number can participate in at most one pairing, and it is allowed to remain unpaired.

Under the condition that the total gained value is at least 00, find the maximum possible number of pairings.

Input Format

The first line contains an integer nn.

The second line contains nn integers a1,a2,,ana_1,a_2,\cdots,a_n.

The third line contains nn integers b1,b2,,bnb_1,b_2,\cdots,b_n.

The fourth line contains nn integers c1,c2,,cnc_1,c_2,\cdots,c_n.

Output Format

Output a single integer on one line: the maximum number of pairings.

3
2 4 8
2 200 7
-1 -2 1

4

Hint

Test points 131 \sim 3: n10n \leq 10, ai109a_i \leq 10^9, bi=1b_i = 1, ci105|c_i| \leq 10^5.
Test points 454 \sim 5: n200n \leq 200, ai109a_i \leq 10^9, bi105b_i \leq 10^5, ci=0c_i = 0.
Test points 6106 \sim 10: n200n \leq 200, ai109a_i \leq 10^9, bi105b_i \leq 10^5, ci105|c_i| \leq 10^5.

Translated by ChatGPT 5