No.2062 Sum of Subset mod 999630629
タグ : / 解いたユーザー数 40
作問者 :
taiga0629kyopro
/ テスター :
nok0
Problem Statement
The well-known prime in competitive programming is $998244353$, but in fact $999630629$ is also a prime. Note that these $2$ primes both appear in this problem statement.
You are given an integer sequence $A$ of length $N$. For a non-empty subset $S$ of $ \lbrace 1,2, \dots , N \rbrace$, define $f(S)$ as follows.
$f(S)= \left( \displaystyle \sum_{i \in S} A_i \right )\ \mathrm{mod} \ 999630629$
There are $2^N-1$ non-empty subsets $S$ of $\lbrace 1,2,\dots , N \rbrace$. Compute $f(S)$ for all of them, and find their sum modulo $998244353$.
(Note that the answer is not taken modulo $999630629$.)
Input
$N$ $A_1$ $A_2$ $\dots$ $A_N$
Output
Output the sum of $f(S)$ modulo $998244353$.
Sample
Sample 1
Input
2 3 5
Output
16
$(A_1) \ \mathrm{mod} \ 999630629=3$
$(A_2) \ \mathrm{mod} \ 999630629=5$
$(A_1+A_2) \ \mathrm{mod} \ 999630629=8$
Therefore, the answer is $3+5+8=16$.
Sample 2
Input
1 1
Output
1
Sample 3
Input
6 1 2 3 4 5 6
Output
672
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。