QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#3543. 隨機 XOR

Statistics

有一個包含 $n$ 個整數嘅陣列 $a$,同埋一個一開始係空嘅陣列 $b$。我哋會將 $a$ 入面一啲元素加落 $b$。每個元素被加入嘅機率都係 $P$,而且同其他元素互相獨立。之後計算 $s$ 嘅值:

$$ s = \bigoplus_{i=0}^{|b|} b_i $$

當中 $\oplus$ 代表按位異或(如果陣列 $b$ 係空,$s$ 就等於零)。你要計算 $s^2$ 嘅期望值。

輸入格式

輸入第一行有三個整數 $n$、$X$ 同 $Y$。機率 $P$ 等於 $\frac{X}{Y}$。

第二行有 $n$ 個用空格分隔嘅整數 $a_i$,即係陣列 $a$ 嘅元素。

$$ 1 \le n \le 10^5 $$

$$ 0 \le X < 10^9 + 7 $$

$$ 0 < Y < 10^9 + 7 $$

$$ X \le Y $$

$$ 0 \le a_i < 10^9 + 7 $$

輸出格式

答案一定可以寫成分數 $\frac{u}{v}$,當中 $u$ 同 $v$ 互質,而且 $v \not\equiv 0 \pmod{10^9+7}$。你只需要輸出一個數:$u \times v^{-1} \bmod (10^9+7)$。

例子

輸入格式 1

3 1 2
2 8 10

輸出格式 1

42

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.