CF1794D.Counting Factorizations

普及+/提高

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The prime factorization of a positive integer mm is the unique way to write it as m=p1e1⋅p2e2⋅…⋅pkek\displaystyle m=p_1^{e_1}\cdot p_2^{e_2}\cdot \ldots \cdot p_k^{e_k}, where p1,p2,…,pkp_1, p_2, \ldots, p_k are prime numbers, p1<p2<…<pkp_1 \lt p_2 \lt \ldots \lt p_k and e1,e2,…,eke_1, e_2, \ldots, e_k are positive integers.

For each positive integer mm, f(m)f(m) is defined as the multiset of all numbers in its prime factorization, that is f(m)=p1,e1,p2,e2,…,pk,ekf(m)={p_1,e_1,p_2,e_2,\ldots,p_k,e_k}.

For example, f(24)=2,3,3,1f(24)={2,3,3,1}, f(5)=1,5f(5)={1,5} and f(1)=f(1)={}.

You are given a list consisting of 2n2n integers a1,a2,…,a2na_1, a_2, \ldots, a_{2n}. Count how many positive integers mm satisfy that f(m)=a1,a2,…,a2nf(m)={a_1, a_2, \ldots, a_{2n}}. Since this value may be large, print it modulo 998 244 353998\,244\,353.

正整数 mm 的质因数分解是将其唯一表示为 m=p1e1⋅p2e2⋅…⋅pkek\displaystyle m=p_1^{e_1}\cdot p_2^{e_2}\cdot \ldots \cdot p_k^{e_k} 的方式,其中 p1,p2,…,pkp_1, p_2, \ldots, p_k 是质数,满足 p1<p2<…<pkp_1 \lt p_2 \lt \ldots \lt p_k,且 e1,e2,…,eke_1, e_2, \ldots, e_k 均为正整数。

对每个正整数 mm,定义 f(m)f(m) 为其质因数分解中所有数构成的多重集,即 f(m)={p1,e1,p2,e2,…,pk,ek}f(m)=\{p_1,e_1,p_2,e_2,\ldots,p_k,e_k\}。

例如,f(24)={2,3,3,1}f(24)=\{2,3,3,1\},f(5)={5,1}f(5)=\{5,1\},而 f(1)={}f(1)=\{\}(空多重集)。

给定一个由 2n2n 个整数 a1,a2,…,a2na_1, a_2, \ldots, a_{2n} 组成的列表。请计算满足 f(m)={a1,a2,…,a2n}f(m)=\{a_1, a_2, \ldots, a_{2n}\} 的正整数 mm 的个数。由于该值可能很大,请输出其对 998 244 353998\,244\,353 取模的结果。

输入格式

The first line contains one integer nn (1≤n≤20221\le n \le 2022).

The second line contains 2n2n integers a1,a2,…,a2na_1, a_2, \ldots, a_{2n} (1≤ai≤1061\le a_i\le 10^6) — the given list.

第一行包含一个整数 nn(1≤n≤20221\le n \le 2022)。

第二行包含 2n2n 个整数 a1,a2,…,a2na_1, a_2, \ldots, a_{2n}(1≤ai≤1061\le a_i\le 10^6)—— 给定的列表。

输出格式

Print one integer, the number of positive integers mm satisfying f(m)=a1,a2,…,a2nf(m)={a_1, a_2, \ldots, a_{2n}} modulo 998 244 353998\,244\,353.

输出一个整数,表示满足 f(m)=a1,a2,…,a2nf(m)={a_1, a_2, \ldots, a_{2n}} 的正整数 mm 的个数,结果对 998 244 353998\,244\,353 取模。

输入输出样例

  • 输入#1

    2
    1 3 2 3

    输出#1

    2
  • 输入#2

    2
    2 2 3 5

    输出#2

    5
  • 输入#3

    1
    1 4

    输出#3

    0

说明/提示

In the first sample, the two values of mm such that f(m)=1,2,3,3f(m)={1,2,3,3} are m=24m=24 and m=54m=54. Their prime factorizations are 24=23⋅3124=2^3\cdot 3^1 and 54=21⋅3354=2^1\cdot 3^3.

In the second sample, the five values of mm such that f(m)=2,2,3,5f(m)={2,2,3,5} are 200,225,288,500200, 225, 288, 500 and 972972.

In the third sample, there is no value of mm such that f(m)=1,4f(m)={1,4}. Neither 141^4 nor 414^1 are prime factorizations because 11 and 44 are not primes.

在第一个样例中,满足 f(m)=1,2,3,3f(m)={1,2,3,3} 的两个 mm 值为 m=24m=24 和 m=54m=54。它们的质因数分解分别为 24=23⋅3124=2^3\cdot 3^1 和 54=21⋅3354=2^1\cdot 3^3。

在第二个样例中,满足 f(m)=2,2,3,5f(m)={2,2,3,5} 的五个 mm 值为 200200、225225、288288、500500 和 972972。

在第三个样例中,不存在满足 f(m)=1,4f(m)={1,4} 的 mm 值。因为 11 和 44 均不是质数,所以 141^4 和 414^1 都不是有效的质因数分解。

输入解题思路,AI测评打分。不知道怎么写?

首页