Mirrors
Statement
Goal
WhenThere are n mirrors numbered 1...n arranged in a row. Mirror i has reflectivity r_i. Find the total amount of light reflected back to the source when
Note that light can be reflected multiple times.
----> | | | | |
light 1 2 3 4 5 ...
Input
Line 1: An integer n for the number of mirrors
Line 2: n space-separated floats r for the reflectivity of the mirrors
Line 2: n space-separated floats r for the reflectivity of the mirrors
Output
Line 1: Total reflected light rounded to 4 decimal places
Constraints
1 ≤ n ≤ 10
0 ≤ r ≤ 1
0 ≤ r ≤ 1
Example
Input
2 0.5 0.500000
Output
0.6667
Tags
Mathematics, Simulation
Difficulty
Easy
Test cases
Test 1 Test
Input
2
0.5 0.500000
Output
0.6667
Validator 1 Validator
Input
2
0.4 0.6
Output
0.6842
Test 2 Test
Input
1
0.011263
Output
0.0113
Validator 2 Validator
Input
1
0.95307
Output
0.9531
Test 3 Test
Input
3
0.313178 0.055436 0.998542
Output
0.9985
Validator 3 Validator
Input
3
0.293747 0.437975 0.666444
Output
0.7615
Test 4 Test
Input
4
0.756643 0.845056 0.439436 0.863778
Output
0.9401
Validator 4 Validator
Input
4
0.471017 0.515089 0.280896 0.247664
Output
0.7277
Test 5 Test
Input
10
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Output
0.0000
Validator 5 Validator
Input
10
0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0
Output
1.0000
Test 6 Test
Input
8
0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0
Output
1.0000
Validator 6 Validator
Input
9
1.0 1.0 1.0 1.0 1.0 1.0 0.9 1.0 1.0
Output
1.0000
Solution language
Solution
Stub generator input