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. JQuery插件之图片轮播插件–slideBox

    来源:http://www.ido321.com/852.html 今天偶然发现了一个比较好用的图片轮播插件—slideBox 先看看效果:http://slidebox.sinaapp.com/ 代 ...

  2. http响应Last-Modified和ETag(转)

    基础知识 1) 什么是”Last-Modified”? 在浏览器第一次请求某一个URL时,服务器端的返回状态会是200,内容是你请求的资源,同时有一个Last-Modified的属性标记此文件在服务期 ...

  3. 第二百六十一、二天 how can I坚持

    昨天在家宅了一天,晚上去看了个电影<寻龙诀>,感觉一般,虽然有黄渤.舒淇.十分打7分吧,画面倒是很震撼. 今天,去了趟东升八家郊野公园,想买个篮球玩玩来,可是超市里的太坑了,都是赠品还拿出 ...

  4. angularjs ng-class 两种用法

    ng-class="{'active':current.actived_tree==item}" ng-class="{true:'label-danger white- ...

  5. hello, angular

    开始系统学习一下angular!首先是hello world.根据官网给出的例子,我们一下做出下面这个东西: <!DOCTYPE html> <html ng-app> < ...

  6. DelphiXE Android的所有权限按照分类总结说明

    相关资料:http://www.delphitop.com/html/Android/2778.html   网络相关的: android.permission.INTERNET 允许程序打开网络套接 ...

  7. Codeforces 602B Approximating a Constant Range(想法题)

    B. Approximating a Constant Range When Xellos was doing a practice course in university, he once had ...

  8. 扩展KMP--求字符串S的所有后缀和字符串T的最长公共前缀

    在解上面这个问题前我们要先解决一个类似的问题:求字符串s的所有后缀和s本身的最长公共前缀: 我们用next[]数组保存这些值: 现在我们假设要求next[ x ],并且next[ i ] 0<i ...

  9. PHP 中运用 elasticsearch

    PHP扩展安装 1. 环境要求:PHP_VERSION >= 5.3.9,composer工具 2. 在E盘新建文件夹命名为elastic,,拷贝composer.phar到      E:/e ...

  10. 高扩展的基于NIO的服务器架构(二)

    接上文高扩展的基于NIO的服务器架构 Reactor模式 如下图所示,将不同事件的检测分离开,当一种事件发生时一个事件处理器EventHandler将通知与该事件处理相对应的专用工作线程 采用这种架构 ...