ACM学习历程—HDU4969 Just a Joke(物理题)

Just a Joke

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

2
1 1 1 1
11904 41076 3561 3613

Sample Output

Why give up treatment
Wake up to code

这道题目是一道高中物理竞赛题,结论是运动轨迹是一个圆弧。如图:

其中轨迹圆相切于起始直线,也就是说轨迹圆的圆心在y轴上。

接下来证明:
采用物理中的微元法:
假设在某位置,经过dt时间,dt非常小,接近于0

位置变化如图。
由于dt很小,所以a角度接近于0。于是包含a角的直角三角形近似接近于一块扇形。于是扇形弧长为ra。然后由dr,ra,v2dt构成的直角三角形得到如下式子:

然后两边同除以dt得:

即:

其中w为角速度,v为径向速度。(当然,用速度分解能更快得出这个结论)
由v1可得角速度
w=v1/R
于是就是一个求解r的微分方程了。(v=dr/dt)
但是发现这个微分方程求解的时候如果换元,换元的时候是令

化简出来如果k=w,那么是个恒等式。

说明是恒成立的。

然后由图中关系便可得轨迹。

不过这个题目不需要求轨迹方程,不过如果知道结论当然更好。这样以后推导中间的几何关系便可得出判断的式子
最后得出的结论是如果arcsin(v1v2)<=(v1/v2)*(D/R)那么能追上。

代码:

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstdlib>
 4 #include <cstring>
 5 #include <cmath>
 6 #include <algorithm>
 7 #include <set>
 8 #include <map>
 9 #include <queue>
10 #include <string>
11 #include <vector>
12 #define inf 0x3fffffff
13 #define eps 1e-10
14
15 using namespace std;
16
17 long long v1, v2, r, d;
18 double x, y;
19
20 int main()
21 {
22     //freopen ("test.txt", "r", stdin);
23     int T;
24     scanf ("%d", &T);
25     for (int times = 0; times < T; ++times)
26     {
27         scanf ("%I64d%I64d%I64d%I64d", &v1, &v2, &r, &d);
28         x = (v1+0.0)/v2;
29         y = (d+0.0)/r;
30         y = x * y;
31         x = asin(x);
32         if (x > y)
33             printf ("Why give up treatment\n");
34         else
35             printf ("Wake up to code\n");
36     }
37     return 0;
38 }

时间: 2024-10-13 01:47:25

ACM学习历程—HDU4969 Just a Joke(物理题)的相关文章

ACM学习历程—HDU 4726 Kia&#39;s Calculation( 贪心&amp;&amp;计数排序)

DescriptionDoctor Ghee is teaching Kia how to calculate the sum of two integers. But Kia is so careless and alway forget to carry a number when the sum of two digits exceeds 9. For example, when she calculates 4567+5789, she will get 9246, and for 12

ACM学习历程—HDU 5023 A Corrupt Mayor&#39;s Performance Art(广州赛区网赛)(线段树)

Problem Description Corrupt governors always find ways to get dirty money. Paint something, then sell the worthless painting at a high price to someone who wants to bribe him/her on an auction, this seemed a safe way for mayor X to make money. Becaus

ACM学习历程—UESTC 1226 Huatuo&#39;s Medicine(数学)(2015CCPC L)

题目链接:http://acm.uestc.edu.cn/#/problem/show/1226 题目就是构造一个对称的串,除了中间的那个只有1个,其余的两边都是对称的两个,自然答案就是2*n-1. 代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <algorithm> #

ACM学习历程—BestCoder Round #75

1001:King's Cake(数论) http://acm.hdu.edu.cn/showproblem.php?pid=5640 这题有点辗转相除的意思.基本没有什么坑点. 代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <algorithm> #include &l

ACM学习历程—HDU5585 Numbers(数论 || 大数)(BestCoder Round #64 (div.2) 1001)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5585 题目大意就是求大数是否能被2,3,5整除. 我直接上了Java大数,不过可以对末尾来判断2和5,对所有位的和来判断3. 代码就不粘了.

ACM学习历程—HDU5587 Array(数学 &amp;&amp; 二分 &amp;&amp; 记忆化 || 数位DP)(BestCoder Round #64 (div.2) 1003)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5587 题目大意就是初始有一个1,然后每次操作都是先在序列后面添加一个0,然后把原序列添加到0后面,然后从0到末尾,每一个都加上1. 例如:a0, a1, a2 => a0, a1, a2, 1, a0+1, a1+1, a2+1 题解中是这么说的:“ 其实Ai为i二进制中1的个数.每次变化A{k+2^i}=A{k}+1,(k<2^?i??)不产生进位,二进制1的个数加1.然后数位dp统计前m个数二

ACM学习历程—HDU 3915 Game(Nim博弈 &amp;&amp; xor高斯消元)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3915 题目大意是给了n个堆,然后去掉一些堆,使得先手变成必败局势. 首先这是个Nim博弈,必败局势是所有xor和为0. 那么自然变成了n个数里面取出一些数,使得xor和为0,求取法数. 首先由xor高斯消元得到一组向量基,但是这些向量基是无法表示0的. 所以要表示0,必须有若干0来表示,所以n-row就是消元结束后0的个数,那么2^(n-row)就是能组成0的种数. 对n==row特判一下. 代码:

ACM学习历程—HDU 5534 Partial Tree(动态规划)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5534 题目大意是给了n个结点,让后让构成一个树,假设每个节点的度为r1, r2, ...rn,求f(x1)+f(x2)+...+f(xn)的最大值. 首先由于是树,所以有n-1条边,然后每条边连接两个节点,所以总的度数应该为2(n-1). 此外每个结点至少应该有一个度. 所以r1+r2+...rn = 2n-2.ri >= 1; 首先想到让ri >= 1这个条件消失: 令xi = ri,则x1+x

ACM学习历程—HDU 5536 Chip Factory(xor &amp;&amp; 字典树)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5536 题目大意是给了一个序列,求(si+sj)^sk的最大值. 首先n有1000,暴力理论上是不行的. 此外题目中说大数据只有10组,小数据最多n只有100.(那么c*n^2的复杂度应该差不多) 于是可以考虑枚举i和j,然后匹配k. 于是可以先把所有s[k]全部存进一个字典树, 然后枚举s[i]和s[j],由于i.j.k互不相等,于是先从字典树里面删掉s[i]和s[j],然后对s[i]+s[j]这个