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

#include"iostream"
using namespace std;
inline double max(double a,double b,double c)
{
a=a>b?a:b;
a=a>c?a:c;
return a;
}
inline double min(double a,double b,double c)
{
a=a<b?a:b;
a=a<c?a:c;
return a;
}
int main()
{
double an;
double tsm[],tsh[],tmh[];
double s,m,h;
s=3600.00/;//周期结束点
m=43200.00/;
h=43200.00/;
while(cin>>an&&an!=-)
{
tsm[]=(*an)/;
tsh[]=(*an)/;
tmh[]=(*an)/;
tsm[]=s-tsm[];
tsh[]=m-tsh[];
tmh[]=h-tmh[];
double sum=;
double x=,y=;
int i,j;
for(i=,j=;;i+=,j+=)
{
tsm[i]=tsm[i-]+s;
tsm[j]=tsm[j-]+s;
if(tsm[i]>&&tsm[j]>)
break;
}
for(i=,j=;;i+=,j+=)
{
tsh[i]=tsh[i-]+m;
tsh[j]=tsh[j-]+m;
if(tsh[i]>&&tsh[j]>)
break;
}
for(i=,j=;;i+=,j+=)
{
tmh[i]=tmh[i-]+h;
tmh[j]=tmh[j-]+h;
if(tmh[i-]>&&tmh[j]>)
break;
}
int a[],b[],c[];
a[]=b[]=c[]=;
a[]=b[]=c[]=;
while(x<=&&y<=)
{
x=max(tsm[a[]],tsh[b[]],tmh[c[]]);
y=min(tsm[a[]],tsh[b[]],tmh[c[]]);
if(x<y)
sum+=(y-x);
if(y==tsm[a[]])
{
a[]+=;
a[]+=;
}
if(y==tsh[b[]])
{
b[]+=;
b[]+=;
}
if(y==tmh[c[]])
{
c[]+=;
c[]+=;
}
}
cout.precision();
cout<<fixed<<sum/<<endl;
}
return ;
}

Tick and Tick的更多相关文章

  1. hdu1006 Tick and Tick

    原题链接 Tick and Tick 题意 计算时针.分针.秒针24小时之内三个指针之间相差大于等于n度一天内所占百分比. 思路 每隔12小时时针.分针.秒针全部指向0,那么只需要计算12小时内的百分 ...

  2. HDU 1006 Tick and Tick 时钟指针问题

    Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  3. hdu 1006 Tick and Tick 有技巧的暴力

    Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

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

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1006 Tick and Tick Time Limit: 2000/1000 MS (Java/Oth ...

  5. hdu 1006 Tick and Tick

    Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. hdu_1006 Tick and Tick(暴力模拟)

    hdu1006 标签(空格分隔): 暴力枚举 好久没有打题了,退队了有好几个月了,从心底不依赖那个人了,原来以为的爱情戏原来都只是我的独角戏.之前的我有时候好希望有个人出现,告诉自己去哪里,做什么,哪 ...

  7. 1006 Tick and Tick

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1006 题意: 24小时中,三个指针之间超过某个度数的时间占所有时间的百分比是多少. 思路:主要是物理和数学 ...

  8. [ACM_模拟] HDU 1006 Tick and Tick [时钟间隔角度问题]

    Problem Description The three hands of the clock are rotating every second and meeting each other ma ...

  9. hdu1006 Tick and Tick (数学题 借鉴了大神的博客)

    先缩短一半的时间:早上的12个小时和下午的12小时对时钟是一样的,因为时钟12小时与0小时的三针位置相同.接着就是了解到每次所有的针从有重合到再次有重合至多有一段连续的段符合三针分离度大于n.所以只要 ...

随机推荐

  1. bzoj 3629 [JLOI2014]聪明的燕姿(约数和,搜索)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3629 [题意] 给定S,找出所有约数和为S的数. [思路] 若n=p1^a1*p2^a ...

  2. HDU 1707

    思路:标记课程表上的课程,询问时遍历课程表,再以字典序输出名字. #include<iostream> #include<stdio.h> #include<stdlib ...

  3. DRAM 内存介绍(一)

    转载自博客大神迈克老狼的blog: http://www.cnblogs.com/mikewolf2002/archive/2012/11/13/2768804.html 参考资料:http://ww ...

  4. SQL游标遍历数据表

    DECLARE @资产编号 VARCHAR(50) ,@gsid VARCHAR(50) DECLARE test_Cursor CURSOR LOCAL FOR SELECT 资产编号,gsid F ...

  5. struts2框架开发的第一个应用

    写这篇博文,主要是帮助那些刚接触struts2框架开发而不知所措的人,希望批评指正 一.先建立一个web project,命名为struts2 二.在webroot/WEB-INF/lib目录下添加如 ...

  6. MATLAB / Simulink on BeagleBone Black

    转自:beagleboard@googlegroups.com邮件组 作者:kevind I have MATLAB / Simulink working with BeagleBone Black. ...

  7. Codeforces 381 简要题解

    做的太糟糕了...第一题看成两人都取最优策略,写了个n^2的dp,还好pre-test良心(感觉TC和CF的pretest还是很靠谱的),让我反复过不去,仔细看题原来是取两边最大的啊!!!前30分钟就 ...

  8. tomcat server获取用户的请求地址

    当用户 与 tomcat之间 用 nginx做跳转时, HttpServletRequest 中的 getRemoteHost()方法获取到的只是nginx的地址,而不能拿到用户真正的请求地址 解决方 ...

  9. hdu 4496 (并差集)

    题意:给出一个图,m条边,输出删除前i条边后该图的联通块的个数. 思路:刚开始想着是不是联通问题,后来看明白题意后知道,如果从最后一条边添加的话,答案就会出来了,就是并差集的操作. #include& ...

  10. Objc基础学习记录1

    1.'-'系在实例方法前头 2.'+'类方法class method 相反; 3.void表示没有返回值; 4.&x 和c语言一样,代表的是x的在内存上的地址; 5.*y指向内存存储空间内的数 ...