Test instructions: people move around, seeking the longest length of the shadow L.
Train of thought: the position of the three-person on D. Note the shadow length =d-x+h-(h-h) *d/x.
1#include <iostream>2#include <stdio.h>3#include <stdlib.h>4#include <memory.h>5#include <string.h>6#include <algorithm>7#include <cmath>8 #defineCLC (A, B) memset (A,b,sizeof (a))9typedefLong Doubleld;TentypedefLong Longll; One Const intN = -; A Const Doubleeps=1e-9; - Const intinf=-100000; - Const intmaxn=1e5+Ten; the Const DoublePi=acos (-1); - using namespacestd; - - Doubleh,h,d; + - DoubleCalcDoublex) + { A returnd-x+h-(h-h) *d/x; at } - - DoubleSolveDoubleLDoubleR) - { - //cout<< "one" <<endl; - DoubleMid,midmid; in Doubled1,d2; - while(r-l>=EPS) to { +Mid= (L+R)/2; -Midmid= (MID+R)/2; thed1=Calc (mid); *D2=Calc (midmid); $ if(d1>=D2)Panax NotoginsengR=Midmid; - Else theL=mid; + } A returnD1; the } + - intMain () $ { $ intT; -scanf"%d",&t); - while(t--) the { -scanf"%LF%LF%LF",&h,&h,&D);Wuyiprintf"%.3lf\n", Solve ((h-h) *d/h,d)); the } - return 0; Wu}
View Code
ZOJ Light Bulb-3203