2014 Multi-University Training Contest 9#1009
Just a JokeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 288 Accepted Submission(s): 111
Problem Description
Here is just a joke, and do not take it too seriously.
Guizeyanhua is the president of ACMM, and people call him President Guizeyanhua. When Guizeyanhua is walking on the road, everyone eyes on him with admiration. Recently, Guizeyanhua has fallen in love with an unknown girl who runs along the circular race track on the playground every evening. One evening, Guizeyanhua stood in the center of the circular race track and stared the girl soulfully again. But this time he decided to catch up with the girl because of his lovesickness. He rushed to the girl and intended to show her his love heart. However, he could not run too far since he had taken an arrow in the knee.
Now your task is coming. Given the maximum distance Guizeyanhua can run, you are asked to check whether he can catch up with the girl. Assume that the values of Guizeyanhua's and the girl's velocity are both constants, and Guizeyanhua, the girl, and the center of the circular race track always form a straight line during the process. Note that the girl and Guizeyanhua can be considered as two points.
Input
The input begins with a line containing an integer T (T<=100000), which indicates the number of test cases. The following T lines each contain four integers V1, V2, R, and D (0<V1, V2, R, D<=10^9, V1<=V2). V1 is the velocity of the girl. V2 is the velocity of Guizeyanhua. R is the radius of the race track. D is the maximum distance President Guizeyanhua can run.
Output
For each case, output "Wake up to code" in a line if Guizeyanhua can catch up with the girl; otherwise output "Why give up treatment" in a line.
Sample Input
21 1 1 111904 41076 3561 3613
Sample Output
Why give up treatmentWake up to code
一开始以为是阿基米德螺线,后来发现不是,因为阿基米德螺线里面点的径向速度v是恒定的,得到的极坐标方程是ρ = aθ (a =v/w) w是圆盘旋转速度, θ = wt。推导过程如下:
一个圆盘以角速度 w 作转动,有一只蚂蚁在圆盘上沿着经过圆心的直线以速度 v 向外爬行,则小虫的运动轨迹为一条等速螺线,也叫阿基米德螺线(Archimedean spiral)。
假设在时刻 t=0 时,小虫位于原点,则在时刻 t 时,小虫位于(x(t),y(t)),其中
x(t)=vt*cos(wt), y(t)=vt*sin(wt)
这就是等速螺线的参数方程。
令圆盘的转角 wt=theta,则得到等速螺线的极坐标方程:
r(theta)=(v/w)*(theta)=a*(theta)
其中a=v/w。
速螺线的极坐标方程:
然后积分求得螺线长度:
可悲的是,这一题不是阿基米德落线,白白wa了那么多次,这一题正解是:因为角速度和外围点一样,所以速度分解可以求得没点的瞬时速度:
vy = sqrt(V2^2-r^2*V1^2/R^2); 又因为dr/dt = r' = vy
1/sqrt(V2^2-r^2*V1^2/R^2)*dr = dt 对两边分别求积分,三角换元: r = R*V2/V1*sinx =>t=R/V1*arcsin(V1/V2) 然后用t*V2就是他跑的距离了。这一题我卡精度,但实际上不需要卡也可以AC!
1 #include <cstring> 2 3 #include <iostream> 4 5 #include <algorithm> 6 7 #include <cstdio> 8 9 #include <cmath> 10 11 #include <map> 12 13 #include <cstdlib> 14 15 #define M(a,b) memset(a,b,sizeof(a)) 16 17 using namespace std; 18 19 20 21 int T; 22 23 double V1,V2,R,D; 24 25 const double eps=1e-8; 26 27 int sgn(double a){return a < -eps ? -1 : a < eps ? 0 : 1;} 28 29 30 31 int main() 32 33 { 34 35 scanf("%d",&T); 36 37 while(T--) 38 39 { 40 41 scanf("%lf%lf%lf%lf",&V1,&V2,&R,&D); 42 43 double t = R/V1*asin(V1/V2); 44 45 double len = V2*t; 46 47 //cout<<len<<endl; 48 49 if(D-len<0) puts("Why give up treatment"); 50 51 else puts("Wake up to code"); 52 53 } 54 55 return 0; 56 57 }