CF1866B.Battling with Numbers
普及/提高-
通过率:0%
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 .
输入格式
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 .
输出格式
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 .
输入输出样例
输入#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 .