#include #include #include #include #include using namespace std; const double PI = acos(-1); double getarea(double w, double h, double r) { if(w >= r && h >= r) return r*r*PI/4; if(w*w+h*h <= r*r) return w*h; if(h > w) swap(w, h); if(w >= r) { assert(h < r); double ang = atan2(h, sqrt(r*r-h*h)); return h * sqrt(r*r-h*h) / 2 + r*r*ang/2; } assert(w < r && h < r); double lowertheta = atan2(sqrt(r*r-w*w), w); double uppertheta = atan2(h, sqrt(r*r-h*h)); assert(uppertheta >= lowertheta); return w * sqrt(r*r-w*w)/2 + h * sqrt(r*r-h*h)/2 + r*r*(uppertheta-lowertheta)/2; } int main() { int n, r, w, h; cin >> n >> r >> w >> h; double ret = 0; while(n--) { int x, y, v; cin >> x >> y >> v; double area = getarea(x, y, r) + getarea(w-x, y, r) + getarea(x, h-y, r) + getarea(w-x, h-y, r); ret += (area * v) / (w * h); } cout << fixed << setprecision(39) << ret << "\n"; }