码迷,mamicode.com
首页 > 其他好文 > 详细

WHU1609 Han Move 思维

时间:2016-04-13 02:00:50      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

Description
Cyy and Fzz are Han Move lovers. One day, they gather together to run. They choose a circular track whose length is L m. Cyy’s speed is A m/s and Fzz’s speed is B m/s. They may choose the direction separately, i.e. they may start with the same direction or different direction. As they’re crazy, they’ll run infinitely. Gatevin, their friend, wonders the possibility of their distance is less than D m. The distance is defined as the distance on the track. The possibility is defined as the ratio between the sum of time satisfying the condition and the total time.
Input
The input file consists of multiple test cases ( around 1000000 ).
Each test case consists of 5 integers L, A, B, D, Dir in a line. The meanings of L, A, B, D are as described above. Dir means whether they are in the same direction. Dir = 1 means they are in the same direction, while Dir = 0 means they are in the opposite direction. ( 1 <= L, A, B, D <= 32768, 0 <= Dir <= 1 )
Output
For each test case, output the possibility rounded to 6 demical places in a line.
Sample Input
1200 200 400 300 0
1200 200 400 300 1
Sample Output
0.500000
0.500000
Hint
Please pay attention to the speed of I/O.
题目大意:告诉你圆形跑道长度L,两个人的速度A,B,0代表反向跑,1代表同向。求两人距离小于D(跑道上的距离)的概率。
思路:两人跑太复杂,可以看做是一个人相对另外一个人静止,就是用(A-B)的速度跑。
可以看出距离小于D的概率与两人的速度无关。
概率就是2*D/L
#include <stdio.h>
int main()
{
int L, A, B, D, Dir;
while(~scanf("%d%d%d%d%d", &L, &A, &B, &D, &Dir)){
if(2*D>=L) printf("1.000000\n");
else printf("%lf\n", 2.0*D/L);
}
return 0;
}

 

 

WHU1609 Han Move 思维

标签:

原文地址:http://www.cnblogs.com/Noevon/p/5385149.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!