SRM547 Div1 Easy(250) Pillars
各dについて、x-y=dとなるロープの張り方を数えれば良い。
#include <algorithm> #include <cmath> using namespace std; class Pillars{public: double getExpectedLength( int w, int x, int y ) { double s = 0; long long c = 0; for ( int d=-x+1; d<=y-1; d++ ) { int n = min(min(x,y),min(x+d,y-d)); double l = hypot(w,d); c += n; s += l*n; } return s/c; }};