hdu 1006(追击相遇问题)

想了半天,写了半天,多次TLE,WA后终于AC。。。 其实只要注意一些问题这个题目思路还是很简单的。

1. 时间是连续走的,从文中“rotating every second”(注意rotate 是加了 ing 的) ,表示每秒钟都在不停的走。 

这个问题坑了我很久, 一开始用一秒一秒模拟, 然后90 时就为6.255。。。 这个是必须错的,然后就知道了不是一秒一秒动的,然后天真的以为可以将一秒分成1000ms来精确,可是出题人怎么可能让我得逞, 果断TLE,发现就是分成10ms也是TLE。。。 无奈只有想新方法。。

既然不能离散成一秒一秒,那么就连续的一起求, 于是就想到了看秒针走一圈中有多少路程是满足要求的。 

这就转变成了3个追击相遇问题, 秒和分针、秒针和时针、分针和时针。 两边的初始位置和速度都可以知道,那么问题也就可以解决了(处理过程有一些繁琐).

总体来说,思路还是不难的,但是写起来确实很考验耐性

              Tick and Tick

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7216    Accepted Submission(s): 1977


Problem Description
The three hands of the clock are rotating every second and meeting each other many times everyday. Finally, they get bored of this and each of them would like to stay away from the other two. A hand is happy if it is at least D degrees from any of the rest. You are to calculate how much time in a day that all the hands are happy.
 
Input
The input contains many test cases. Each of them has a single line with a real number D between 0 and 120, inclusively. The input is terminated with a D of -1.
 
Output
For each D, print in a single line the percentage of time in a day that all of the hands are happy, accurate up to 3 decimal places.
 
Sample Input
0 120 90 -1
 
Sample Output
100.000 0.000 6.251
 
Author
PAN, Minghao
 
Source
 
Recommend
JGShining
 
原文地址:https://www.cnblogs.com/chenhuan001/p/3117979.html