NOI '22 Multi-Provincial Team Selection P4 - Card

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type

Tommy has a multiset of n positive integers S={s1,s2,,sn} and m queries. In query i, he has ci prime numbers p1,p2,,pci and asks: how many multisets SS satisfy that all given primes p divide the product of all elements of S? Output the answer modulo 998244353.

Constraints

n106

si,pi2000

m1500

ci18000

Test n m ci Other restrictions
1, 2 10 10 20 si30
3, 4, 5 10 20 50 None
6, 7, 8 106 1500 104 si30
9, 10, 11 104 1000 5000 si500
12, 13 1000 100 1000 None
14, 15, 16, 17 5000 600 7000 None
18, 19, 20 106 1500 18000 None

Input Specification

The first line contains a positive integer n.

The second line contains n positive integers s1,s2,,sn.

The third line contains a positive integer m.

The next m lines begin with a positive integer ci. ci primes follow, describing a query.

Output Specification

Output m lines, corresponding to the answer for the corresponding query.

Sample Input 1

Copy
5
10 2 10 5 46
4
2 2 5
2 2 23
1 3
1 23

Sample Output 1

Copy
27
16
0
16

Attachments

Attachments can be found here.


Comments

There are no comments at the moment.