No.2313 Product of Subsequence (hard)
Problem Statement
You are given a sequence $A$ of positive integers of length $N$. There are $2^N-1$ non-empty subsequences of $A$. How many of them have a product of all elements that is a multiple of $K$? Output the answer modulo $998244353$.
Input
$N\ K$ $A_1\ A_2\ \cdots\ A_N$
- $1\leq N\leq 3\times 10^5$
- $1\leq K\leq 10^{9}$
- $1\leq A_i\leq 10^{18}$
- All inputs are integers.
Output
Output the number of non-empty subsequences whose product is a multiple of $K$, modulo $998244353$.
Sample
Sample 1
Input
3 4 2 4 6
Output
5
The non-empty subsequences whose product of all elements is a multiple of $4$ are the following $5$: $(4),(2,4),(2,6),(4,6),(2,4,6)$.
Sample 2
Input
4 6 2 2 3 3
Output
9
The non-empty subsequences whose product of all elements is a multiple of $6$ are: $4$ of $(2,3)$, $2$ of $(2,2,3)$, $2$ of $(2,3,3)$, and $1$ of $(2,2,3,3)$.
Sample 3
Input
20 360 678 545 651 790 694 268 851 318 295 814 359 941 504 592 378 874 989 522 571 724
Output
855936
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
とりゐ