QOJ.ac

QOJ

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

#3543. XOR แบบสุ่ม

Statistics

มีอาร์เรย์ $a$ ที่มีจำนวนเต็ม $n$ ตัว และมีอาร์เรย์ $b$ ซึ่งเริ่มต้นว่างเปล่า เราจะเพิ่มสมาชิกบางตัวของ $a$ ลงใน $b$ สมาชิกแต่ละตัวจะถูกเพิ่มด้วยความน่าจะเป็น $P$ โดยเป็นอิสระจากสมาชิกตัวอื่น จากนั้นคำนวณค่า $s$ ดังนี้:

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

โดยที่ $\oplus$ คือการดำเนินการ XOR ระดับบิต (หากอาร์เรย์ $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.