Record several interesting questions that you have encountered in the previous section and try again later ~~
Question Link
When div1 is abused, div2 is started with the trumpet. The question is very simple:
A rectangular area is vertically divided into three parts, three different rivers, one traveling from the lower left to the upper right corner, the speed in the Three Rivers is different V1, V2, V3, another V is the vertical speed along the river. Ask the minimum time.
When I saw this question, I thought of a previous question: ignoring the river's width, we discussed with su_xing that when considering the river width, we can use a theorem, that isFerma principles.
Description of ferma principlesWhen light is transmitted from one point to another in any media, it is transmitted along the path with the shortest time. Here we need the shortest path, so we can follow the refraction rule of light. At that time, I only mentioned the conjecture and did not think much about it. This question is not for this theorem. As long as the angle of the first exit is enumerated by three points, the angle of the next two rivers can be introduced through the method of light refraction, then, go to the end point vertically and obtain the minimum value.
1 # Include <cstdlib> 2 # Include <cctype> 3 # Include <cstring> 4 # Include <cstdio> 5 # Include <cmath> 6 # Include <algorithm> 7 # Include <vector> 8 # Include < String > 9 # Include <iostream> 10 # Include <sstream> 11 # Include <map> 12 # Include < Set > 13 # Include <queue> 14 # Include <stack> 15 # Include <fstream> 16 # Include <numeric> 17 # Include <iomanip> 18 # Include <bitset> 19 Using Namespace STD; 20 # Define Min (x, y) (x> Y? Y: X) 21 # Define Max (x, y) (x <Y? Y: X) 22 # Define ABS (x) (x> 0? X :(-x )) 23 # Define Pi (ACOs (-1 )) 24 25 Class Ellysthreerivers 26 { 27 Public : 28 Int L, WV; 29 Vector <Int > Wl; 30 Vector < Int > Sv; 31 32 Double Get ( Double R ){ 33 Double H = 0 , T = 0 ; 34 H + = Double (WL [ 0 ]) * Tan (R ); 35 T + = Double (WL [ 0 ])/Cos (r )/ Double (SV [ 0 ]); 36 R = Asin ( Double (SV [ 1 ])/ Double (SV [0 ]) * Sin (R )); 37 H + = Double (WL [ 1 ]) * Tan (R ); 38 T + = Double (WL [ 1 ])/Cos (r )/ Double (SV [ 1 ]); 39 R = Asin ( Double (SV [2 ])/ Double (SV [ 1 ]) * Sin (R )); 40 H + = Double (WL [ 2 ]) * Tan (R ); 41 T + = Double (WL [ 2 ])/Cos (r )/ Double (SV [ 2 ]); 42 T + = FABS ( Double (L)-H )/( Double ) WV; 43 Return T; 44 } 45 46 Double Getmin ( Int Length, Int Walk, vector < Int > Width, vector <Int > Swim ){ 47 L = Length; 48 WV = Walk; 49 WL = Width; 50 SV = Swim; 51 52 Double L = 0 , R = PI/ 2.0 ; 53 Double LL = (L * 2.0 + R )/ 3.0 ; 54 Double RR = (L + R * 2.0 )/ 3.0 ; 55 While (Rr-ll> 1E- 12 ){ 56 Double Lt = Get (Ll ); 57 Double RT = Get (Rr ); 58 If (LT> = RT ){ 59 L = Ll; 60 } Else { 61 R = RR; 62 } 63 LL = (L * 2.0 + R )/ 3.0 ; 64 RR = (L + R * 2.0 )/ 3.0 ; 65 } 66 Return Get (Rr ); 67 } 68 };
It's a pity that the game has no brains and the accuracy is reduced.StF, After the game changed the precision on the T-T
Div1 500 does not have this question, but has multiple rivers and can only take Integer Points. It seems to be a DP question to be optimized.