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. bfs CCF2016第七次 游戏

    // bfs CCF2016第七次 游戏 // 思路: // O(300*100*100) // 直接暴搜 // 注意,同一格同一时间不能经过两次!!! #include <bits/stdc+ ...

  2. C++单例模板

    #pragma once namespace MyGame { template<typename T> class Global { public: static void Create ...

  3. ISO/IEC 14496 文档内容简介, MPEG标准

    ISO/IEC 14496是MPEG专家组制定的MPEG-4标准于1998年10月公布第1版,1999年1月成为国际标准,1999年12月公布了第2版,2000年初成为国际标准. 全文分为21个部分: ...

  4. 探索ORACLE之ASM概念

    一.     ASM(自动存储管理)的来由: ASM是Oracle 10g R2中为了简化Oracle数据库的管理而推出来的一项新功能,这是Oracle自己提供的卷管理器,主要用于替代操作系统所提供的 ...

  5. GUI、模块化与结对编程(homework-03)

    摘要: 在本次作业博客里,我将主要阐述作业3的收获.作业3表面是将之前的程序转换为图形界面(之前程序见http://www.cnblogs.com/shone/p/3348372.html),然而本质 ...

  6. gulp之静态资源防缓存处理

    最近,因为校友网项目开始有些规模了.开始就要考虑对静态资源进行工程自动化的管理.一讲到前端的自动化工具,大家或许都会想到Grunt,Gulp,或者百度的FIS.这三个都有各自的特点,大家可以依据自己的 ...

  7. Spring Data JPA教程, 第四部分: JPA Criteria Queries(未翻译)

    The third part of my Spring Data JPA tutorialdescribed how you can create custom queries by using qu ...

  8. 微信小程序正式上线 可置于聊天窗口顶部

    历经一年的等待后,小程序在2017年1月9日凌晨终于揭开神秘面纱,正式上线. 微信小程序推广海报 随着小程序正式上线,用户现在可以通过二维码.搜索等方式体验到开发者们开发的小程序了. 用户只要将微信更 ...

  9. UVA12219

    //by Rujia Liu /* 字符串的对比是缓慢的. 鉴于这道题最多只有四个小写字母, 也就是最多26*4种情况, 我们完全可以用整数来代替字符串. 一种比较简单的做法是把字符串看成一个四位的2 ...

  10. MEF 编程指南(六):导出和元数据

    声明导出解释了部件导出服务的基础知识和价值观(Values).有时候出于种种原因,导出关联信息是非常必要的.通常,用于解释关于功能公共契约的具体实现.允许导入满足约束要求的导出,或者导入所有可用的实现 ...