QOJ.ac

QOJ

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

#3543. XOR ngẫu nhiên

Statistics

Có một mảng $a$ chứa $n$ số nguyên. Ngoài ra, có một mảng $b$ ban đầu rỗng. Một số phần tử của $a$ sẽ được thêm vào $b$. Mỗi phần tử được thêm vào với xác suất $P$, độc lập với các phần tử khác. Sau đó, giá trị $s$ được tính như sau:

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

trong đó $\oplus$ là phép XOR theo bit (nếu mảng $b$ rỗng thì $s$ bằng không). Bạn cần tính giá trị kỳ vọng của $s^2$.

Dữ liệu vào

Dòng đầu tiên của dữ liệu vào chứa ba số nguyên $n$, $X$ và $Y$. Xác suất $P$ bằng $\frac{X}{Y}$.

Dòng thứ hai chứa $n$ số nguyên $a_i$ cách nhau bởi dấu cách — các phần tử của mảng $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 $$

Dữ liệu ra

Đáp án luôn có thể biểu diễn dưới dạng phân số $\frac{u}{v}$, trong đó $u$ và $v$ nguyên tố cùng nhau và $v \not\equiv 0 \pmod{10^9+7}$. Bạn chỉ cần in ra một số — $u \times v^{-1} \bmod (10^9+7)$.

Ví dụ

Dữ liệu vào 1

3 1 2
2 8 10

Dữ liệu ra 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.