1006 Tick and Tick

1006题:

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

思路:

要求:时针、分针、秒针之间的间隔区间大于某个角度(这个角度由用户输入)的总时间占一天之中总时间的比例。

可以这样理解:

1.我们只需算出时钟从12点整(3个指针重合),到下一次12点整(3个指针再次重合)这12个小时的时间过程中,这3个指针之间的区间间隔大于制定角度的时间(即秒数)即可。

2.既然是算秒数,我们可以算这12个小时,也就是在720分钟当中,每分钟有多少秒这3个指针的位置符合要求。

3.于是,我们计算在h:m:s(h时m分s秒)时刻,这3个指针偏离12点整位置的角度(因为这样便于计算这3个指针的相对角度差,即它们相距的区间):

首先:这3个指针的角速度:

  1. #define V_SEC 6.0       //秒针角速度:6度每秒
  2. #define V_MIN 0.1       //分针角速度:0.1度每秒
  3. #define V_HOU 1.0/120   //时针角速度:1/120度每秒

然后:这3个指针偏离0点的角度:

  1. #define A_SEC s*6                   //秒针角度:6*s
  2. #define A_MIN m*6+s*0.1             //分针角度:0.1度*60s*m分钟+0.1度*s秒
  3. #define A_HOU h*30+m*0.5+s/120.0    //时针角度:1/120度*3600s*h小时+1/120度*60s*m分钟+1/120*s秒

4.

时间: 2024-11-08 15:54:19

1006 Tick and Tick的相关文章

HDU 1006 Tick and Tick 解不等式解法

一开始思考的时候觉得好难的题目,因为感觉很多情况,不知道从何入手. 想通了就不难了. 可以转化为一个利用速度建立不等式,然后解不等式的问题. 建立速度,路程,时间的模型如下: /*************************************************************************** * * * 秒钟的速度s=6°/s,分针是1/10°/s,时针是1/120°/s * * 所以相对速度s_m=59/10°/s,s_h=719/120°/s,m_h=12

HDU 1006 Tick and Tick(时钟,分钟,秒钟角度问题)

传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1006 Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 22203    Accepted Submission(s): 5877 Problem Description The three hands of the

hdu 1006 Tick and Tick 有技巧的暴力

Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16707    Accepted Submission(s): 4083 Problem Description The three hands of the clock are rotating every second and meeting each ot

hdu 1006 Tick and Tick

Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19764    Accepted Submission(s): 5164 Problem Description The three hands of the clock are rotating every second and meeting each ot

HDU 1006 Tick and Tick 时钟指针问题

Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10194    Accepted Submission(s): 2859 Problem Description The three hands of the clock are rotating every second and meeting each ot

HDU1006 Tick and Tick【计算几何】

Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10770    Accepted Submission(s): 3008 Problem Description The three hands of the clock are rotating every second and meeting each o

Tick and Tick

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 th

HDU ACM 1006 Tick and Tick

题意:一个钟的三个指针在不停的转动,他们厌烦了这样,当他们互相的距离角度大于等于D时,他们会很开心,问一天之中他们happy的时间占总时间的百分比. 分析:只要找到某一分钟内,他们happy的时间,然后钟每过12个小时相当于43200秒复原一次.因此总时间就是43200秒,只要求出在这43200的happy时间,即可求出百分比.枚举12*60分钟,看一分钟内有多少秒是happy的时间,一分钟内解三个不等式可得到区间. 步骤: 1.列出指针(h:m:s)与度数(rh:rm:rs)之间的关系: 秒针

HDU1006 Tick and Tick

题目链接:https://vjudge.net/problem/HDU-1006 题目大意: 给定一个\(D\),问时钟上时针.分针.秒针之间的角度差都大于或等于\(D\)的概率是多少. 知识点: 暴力 解题思路: 枚举时与分,对于每一分钟,设秒数为\(s\),由时.分.秒可以推出各针当前的角度.任意两针之间的角度差大于等于\(D\)小于等于\((360-D)\),由这条关系可以推出三条不等式,求出关于\(s\)的三个区间,\(s\)在这一分钟的合法区间即为这三个区间的交集. AC代码: 1 #