QOJ.ac

QOJ

时间限制: 1 s 内存限制: 2048 MB 总分: 100

#8246. 荆棘花园

统计

Eddy 拥有一个矩形花园,他注意到有一些入侵者在他的花园里践踏。他有一些想要保护的植物。他雇佣了一名助手 Zyra 来巡逻并保护他的花园。

Zyra 不想费心去监控花园,所以她在花园边界内随机选择一个位置,种下了一个荆棘圆圈。如果一株植物严格位于荆棘圆圈内,则认为该植物受到保护——也就是说,植物到荆棘圆圈中心的距离小于圆圈的半径。荆棘圆圈可能会延伸到矩形花园的边界之外,尽管所有植物都位于花园内部或边界上。

鉴于 Zyra 放置荆棘圆圈的随机性,请计算受保护植物价值的期望值。注意,Zyra 的荆棘圆圈不必以整数坐标为中心。

输入格式

第一行包含四个整数 $n$ ($1 \le n \le 10$),$r$ ($1 \le r \le 2,000$),$w$ 和 $h$ ($1 \le w, h \le 1,000$),其中 $n$ 是 Eddy 花园中植物的数量,$r$ 是 Zyra 荆棘圆圈的半径,$w$ 是 Eddy 花园的宽度,$h$ 是花园的高度。

接下来的 $n$ 行,每行包含三个整数 $x$ ($0 \le x \le w$),$y$ ($0 \le y \le h$) 和 $v$ ($1 \le v \le 1,000$),其中 $(x, y)$ 表示植物相对于 Eddy 花园左下角的位置,$v$ 是该植物的价值。没有两株植物位于同一位置。

输出格式

输出一个实数,即受 Zyra 荆棘圆圈保护的植物价值的期望值。任何与标准答案的绝对误差或相对误差在 $10^{-9}$ 以内的答案都将被接受。

样例

样例输入 1

3 50 100 100
30 10 3
40 10 7
50 90 8

样例输出 1

8.41906486932450803806204930879

样例输入 2

2 5 3 4
0 0 10
3 4 15

样例输出 2

25.0

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.