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. Android版本判断

    尽管Android向下兼容不好,但是一个程序还是可以在多个平台上跑的.向下兼容不好,接口改变,新的平台上不能用旧的API,旧的平台更不可能用新的API,不等于一个平台需要一个APK.可以在高版本的SD ...

  2. 用原生javascript模拟经典FC游戏公路争霸

    #用原生javascript模拟经典FC游戏公路争霸 前几天看了园子里面的随笔 [原生javascript开发仿微信打飞机小游戏](http://www.cnblogs.com/Mr-Nobody/p ...

  3. RabbitMQ (五)主题(Topic) -摘自网络

    虽然使用direct类型改良了我们的系统,但是仍然存在一些局限性:它不能够基于多重条件进行路由选择. 在我们的日志系统中,我们有可能希望不仅根据日志的级别而且想根据日志的来源进行订阅.这个概念类似un ...

  4. socket.io的抽象实现:engine.io

    engine.io是一个socket.io的抽象实现,作为socket.io的服务器和浏览器之间交换的数据的传输层.它不会取代Socket.IO,它只是抽象出固有的复杂性,支持多种浏览器,设备和网络的 ...

  5. HDU 5675 ztr loves math (数学推导)

    ztr loves math 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/A Description ztr loves re ...

  6. 解读XMP元数据中ALAssetRepresentation

    当用户进行某些更改(裁剪,消除红眼,...),在内置 Photos.app iOS上,这些更改将不会应用到由相应 fullResolutionImage 返回的 ALAssetRepresentati ...

  7. POJ 3237 Tree (树链剖分 路径剖分 线段树的lazy标记)

    题目链接:http://poj.org/problem?id=3237 一棵有边权的树,有3种操作. 树链剖分+线段树lazy标记.lazy为0表示没更新区间或者区间更新了2的倍数次,1表示为更新,每 ...

  8. AfxGetMainWnd()函数用法

    CWnd* AfxGetMainWnd( ); 使用AfxGetMainWnd函数获取MFC程序中的主框架类指针是一个常用作法. 就是获得应用程序主窗口的指针,AfxGetMainWnd()-> ...

  9. JPA project Change Event Handler问题解决[转]

    转至:http://my.oschina.net/cimu/blog/278724 这是Eclipse中的一个GUG: Bug 386171 - JPA Java Change Event Handl ...

  10. shiro安全三部曲

    源:http://blog.csdn.net/boonya/article/details/8233435 第一部分 Shiro简介及项目目录结构 最新官方示例下载:http://shiro.apac ...