CF1866B.Battling with Numbers
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
On the trip to campus during the mid semester exam period, Chaneka thinks of two positive integers X and Y. Since the two integers can be very big, both are represented using their prime factorisations, such that:
- X=A1B1×A2B2×…×ANBN (each Ai is prime, each Bi is positive, and A1<A2<…<AN)
- Y=C1D1×C2D2×…×CMDM (each Cj is prime, each Dj is positive, and C1<C2<…<CM)
Chaneka ponders about these two integers for too long throughout the trip, so Chaneka's friend commands her "Gece, deh!" (move fast) in order to not be late for the exam.
Because of that command, Chaneka comes up with a problem, how many pairs of positive integers p and q such that LCM(p,q)=X and GCD(p,q)=Y. Since the answer can be very big, output the answer modulo 998244353.
Notes:
- LCM(p,q) is the smallest positive integer that is simultaneously divisible by p and q.
- GCD(p,q) is the biggest positive integer that simultaneously divides p and q.
期中考试期间,Chaneka 在前往校园的途中想到了两个正整数 X 和 Y。由于这两个整数可能非常大,因此均以质因数分解形式给出,即:
- X=A1B1×A2B2×…×ANBN(其中每个 Ai 均为质数,每个 Bi 均为正整数,且 A1<A2<…<AN);
- Y=C1D1×C2D2×…×CMDM(其中每个 Cj 均为质数,每个 Dj 均为正整数,且 C1<C2<…<CM)。
Chaneka 在旅途中长时间思考这两个整数,以至于她的朋友催促她:“Gece, deh!”(快点!),以免考试迟到。
受此催促启发,Chaneka 想到了一个问题:有多少对正整数 p 和 q,满足 LCM(p,q)=X 且 GCD(p,q)=Y?由于答案可能非常大,请将答案对 998244353 取模后输出。
注:
- LCM(p,q) 表示能同时被 p 和 q 整除的最小正整数;
- GCD(p,q) 表示能同时整除 p 和 q 的最大正整数。
输入格式
The first line contains a single integer N (1≤N≤105) — the number of distinct primes in the prime factorisation of X.
The second line contains N integers A1,A2,A3,…,AN (2≤A1<A2<…<AN≤2⋅106; each Ai is prime) — the primes in the prime factorisation of X.
The third line contains N integers B1,B2,B3,…,BN (1≤Bi≤105) — the exponents in the prime factorisation of X.
The fourth line contains a single integer M (1≤M≤105) — the number of distinct primes in the prime factorisation of Y.
The fifth line contains M integers C1,C2,C3,…,CM (2≤C1<C2<…<CM≤2⋅106; each Cj is prime) — the primes in the prime factorisation of Y.
The sixth line contains M integers D1,D2,D3,…,DM (1≤Dj≤105) — the exponents in the prime factorisation of Y.
第一行包含一个整数 N(1≤N≤105)—— 表示 X 的质因数分解中不同质数的个数。
第二行包含 N 个整数 A1,A2,A3,…,AN(2≤A1<A2<…<AN≤2⋅106;每个 Ai 均为质数)—— 表示 X 的质因数分解中的质数。
第三行包含 N 个整数 B1,B2,B3,…,BN(1≤Bi≤105)—— 表示 X 的质因数分解中的指数。
第四行包含一个整数 M(1≤M≤105)—— 表示 Y 的质因数分解中不同质数的个数。
第五行包含 M 个整数 C1,C2,C3,…,CM(2≤C1<C2<…<CM≤2⋅106;每个 Cj 均为质数)—— 表示 Y 的质因数分解中的质数。
第六行包含 M 个整数 D1,D2,D3,…,DM(1≤Dj≤105)—— 表示 Y 的质因数分解中的指数。
输出格式
An integer representing the number of pairs of positive integers p and q such that LCM(p,q)=X and GCD(p,q)=Y, modulo 998244353.
一个整数,表示满足 LCM(p,q)=X 且 GCD(p,q)=Y 的正整数对 (p,q) 的数量,对 998244353 取模。
输入输出样例
输入#1
4 2 3 5 7 2 1 1 2 2 3 7 1 1
输出#1
8
输入#2
2 1299721 1999993 100000 265 2 1299721 1999993 100000 265
输出#2
1
输入#3
2 2 5 1 1 2 2 3 1 1
输出#3
0
说明/提示
In the first example, the integers are as follows:
- X=22×31×51×72=2940
- Y=31×71=21
The following are all possible pairs of p and q:
- p=21, q=2940
- p=84, q=735
- p=105, q=588
- p=147, q=420
- p=420, q=147
- p=588, q=105
- p=735, q=84
- p=2940, q=21
In the third example, the integers are as follows:
- X=21×51=10
- Y=21×31=6
There is no pair p and q that simultaneously satisfies LCM(p,q)=10 and GCD(p,q)=6.
在第一个例子中,整数如下:
- X=22×31×51×72=2940
- Y=31×71=21
以下是所有可能的 p 和 q 的组合:
- p=21, q=2940
- p=84, q=735
- p=105, q=588
- p=147, q=420
- p=420, q=147
- p=588, q=105
- p=735, q=84
- p=2940, q=21
在第三个例子中,整数如下:
- X=21×51=10
- Y=21×31=6
不存在同时满足 LCM(p,q)=10 和 GCD(p,q)=6 的整数对 p 和 q。
输入解题思路,AI测评打分。不知道怎么写?