2014
02-27

# Dog and dog

Nowadays, Xiaoyang thinks of a simple problem. The problem is derive from primary school: Two men get close with the same speed v1, there is a dog run between them with speed v2. It is easy to answer the question that how long dog has run (D) before they meet. Since it is so easy, he want to change this problem. Two men can see each other within 10 meters, if their distance less than 10 meters, then they stop. The dog can run at most L2 meters. At first, two man’s distance is L1 meters, their speeds are changed. The left man’s speed becomes and the right man’s speed becomes . The dog’s speed also changed to

the first line N, then N lines follows
each line has 4 parameters L1, L2, V1, V2;

0<=L1,L2<=100,0<v1,v2<=100

the first line N, then N lines follows
each line has 4 parameters L1, L2, V1, V2;

0<=L1,L2<=100,0<v1,v2<=100

2
9 1 2 3
47 11 25 9

0
11

# 当初我看到它的公式这么复杂，所以就一下子忽略这题了，想起来还真有点后悔。

好的，我翻译一下这一的意思吧！其实就是告诉你两个人和一条狗各时刻的瞬时速度，让你求出两人相遇的时候狗跑了多长的距离。当然，这里的相遇只需要两人相距10m以内。这个看上去很复杂的积分题如果在你做的时候注意一些细节，那么你就可以瞬间秒杀它了。

View Code
 1 #include<stdio.h>
2 #include<math.h>
3 #include<stdlib.h>
4 #include<string.h>
5
6 int main()
7 {
8     int T;
9     double s, l1, l2, v1, v2;
10
11     scanf("%d", &T);
12     while(T--)
13     {
14         scanf("%lf%lf%lf%lf", &l1, &l2, &v1, &v2);
15         s=cos(1)*1.55741*v2*(l1-10)/v1/sin(1);
16         if(s<0)printf("0\n");
17         else if(s>l2)printf("%.0lf\n", l2);
18         else printf("%.0lf\n", s);
19     }
20     return 0;
21 }

written by Lyon

1. Often We don’t set up on weblogs, but I would like to condition that this established up really forced me individually to do this! considerably outstanding publish

2. 换句话说，A[k/2-1]不可能大于两数组合并之后的第k小值，所以我们可以将其抛弃。
应该是，不可能小于合并后的第K小值吧

3. 为什么for循环找到的i一定是素数叻，而且约数定理说的是n=p1^a1*p2^a2*p3^a3*…*pk^ak，而你每次取余都用的是原来的m，也就是n