Problem Statement
Definition
- Class:
- Pillars
- Method:
- getExpectedLength
- Parameters:
- int, int, int
- Returns:
- double
- Method signature:
- double getExpectedLength(int w, int x, int y)
- (be sure your method is public)
Notes
- Your return value must have a relative or an absolute error of less than 1e-9.
- In this task, the expected rope length can be computed as the average rope length over all possible cases.
Constraints
- w will be between 1 and 1000, inclusive.
- x will be between 1 and 100,000, inclusive.
- y will be between 1 and 100,000, inclusive.
Examples
1
1
1
Returns: 1.0
The rope always has a length of 1.
1
5
1
Returns: 2.387132965131785
There are 5 possible (equiprobable) cases in which the length of the rope is 1, sqrt(2), sqrt(5), sqrt(10) and sqrt(17). The correct answer is the arithmetic average of these 5 numbers.
2
3
15
Returns: 6.737191281760445
10
15
23
Returns: 12.988608956320535
1000
100000
100000
Returns: 33381.38304701605
1
99175
56445
Returns: 32073.471757648073
// precision is not too great, but seems ok
741
98283
97708
Returns: 32694.75809065241
772
97431
92415
Returns: 31758.202091392817
987
98228
96988
Returns: 32589.00970552789
890
92714
96949
Returns: 31712.49684962615
884
99111
94672
Returns: 32402.59188274667
741
98835
90385
Returns: 31806.143660389673
729
92658
92366
Returns: 30866.59996029441
746
98939
97438
Returns: 32765.82263936255
808
93569
91507
Returns: 30895.89432876109
849
90577
92202
Returns: 30511.110044647055
963
98047
96381
Returns: 32459.944104889895
917
92247
95421
Returns: 31356.225216130268
976
99917
90443
Returns: 32072.809658547325
706
97598
97448
Returns: 32533.942518992055
755
93628
99334
Returns: 32299.044059147163
1000
94941
97711
Returns: 32184.135418201913
764
91934
99803
Returns: 32193.015738418748
801
95554
90102
Returns: 31080.165714689017
788
92938
99183
Returns: 32183.11427643082
867
94321
90666
Returns: 30917.68049883712
717
98053
97904
Returns: 32686.415243153057
998
97740
90882
Returns: 31646.771878422198
905
92995
99484
Returns: 32261.73462507481
810
96526
93249
Returns: 31700.36466772312
907
97517
96124
Returns: 32321.451176681683
785
96134
96755
Returns: 32181.491324592185
960
90202
97048
Returns: 31415.623263082023
819
97532
94947
Returns: 32137.140460237355
806
97015
98420
Returns: 32612.35196213513
880
93996
94931
Returns: 31530.840430364417
1
100000
100000
Returns: 33333.33344872877
1000
1
100000
Returns: 50028.496625165004
1
1
100000
Returns: 49999.50006935564
100
100000
100000
Returns: 33334.04348856876
1000
100000
10000
Returns: 45374.871961122386
1000
50000
50000
Returns: 16749.035733819004
10
100000
100000
Returns: 33333.342735219885
44
100000
100000
Returns: 33333.48670500142
1000
99999
99998
Returns: 33380.88362205062
1000
99999
99999
Returns: 33381.05009484778
998
88888
99999
Returns: 31941.31591403921
1000
99999
100000
Returns: 33381.216574215534
1000
90000
90000
Returns: 30052.226096239192
1000
92673
92673
Returns: 30942.03323926141