Tick and Tick

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16633    Accepted Submission(s): 4059

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
 
Author
PAN, Minghao
 
Source
 
之前一秒一秒离散地模拟,一直wa。
最后看了题解,是看作连续来做。
由角速度求出相对角速度,再求出每两根针的周期(经过多久再次重合)。然后求12个小时内每两根针(3组)每个周期happy time的交集的和。
 
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std; const double h_m=11.0/,h_s=719.0/,m_s=59.0/; //相对角速度
const double Th_m=43200.0/,Th_s=43200.0/,Tm_s=3600.0/; //周期 int main()
{
double d;
while(scanf("%lf",&d)!=EOF&&d>=)
{
///d/h_m
double sh_m=d/h_m;
double eh_m=(360.0-d)/h_m;
double sh_s=d/h_s;
double eh_s=(360.0-d)/h_s;
double sm_s=d/m_s;
double em_s=(360.0-d)/m_s;
double s1,e1,s2,e2,s3,e3,s4,e4,res=;
for(s1=sh_m,e1=eh_m;e1<=43200.000001;s1+=Th_m,e1+=Th_m)
{
for(s2=sh_s,e2=eh_s;e2<=43200.000001;s2+=Th_s,e2+=Th_s)
{
if(e1<=s2)
break;
if(e2<=s1)
continue;
for(s3=sm_s,e3=em_s;e3<=43200.000001;s3+=Tm_s,e3+=Tm_s)
{
if(s3>=e2||s3>=e1)
break;
if(e3<=s2||e3<=s1)
continue;
s4=max(s1,max(s2,s3));
e4=min(e1,min(e2,e3));
res+=(e4-s4);
}
}
}
printf("%.3lf\n",res/);
}
return ;
}

HDU_1006_Tick and Tick的更多相关文章

  1. STM32F10xxx 之 System tick Timer(SYSTICK Timer)

    背景 研究STM32F10xxx定时器的时候,无意间看到了System tick Timer,于是比较深入的了解下,在此做个记录. 正文 System tick Timer是Cotex-M内核的24位 ...

  2. 进入OS前的两步之System tick

    OK,继续向操作系统迈进.由简入繁,先实现两个小功能.第一个是system tick,第二个是任务切换(PendSV).一个是操作系统的心跳,一个是操作系统的并发处理的具体实现. System tic ...

  3. 9G10内核时钟tick实现

    9G10中PIT(Periodic Interval Timer)提供OS调度中断,它提供了最高精度和最有效的管理(即使系统长时间响应).一. 硬件PIT目标是提供OS的周期中断.PIT提供一个可编程 ...

  4. 异步等待时,在异步前弹出窗口的TIMER,不会TICK

    窗体中用FORMS.TIMER,TICK不会走.改用TIMERS.TIMER 则正常.

  5. 在Silverlight中的DispatcherTimer的Tick中使用基于事件的异步请求

    需求:在silverlight用户界面上使用计时器定时刷新数据. 在 Silverlight 中的 DispatcherTimer 的 Tick 事件 中使用异步请求数据时,会出现多次请求的问题,以下 ...

  6. (转载)PHP源代码分析- tick(s)

    (转载)http://bbs.phpchina.com/forum.php?mod=viewthread&tid=94534 昨天有位朋友在杭州的PHPer群里面贴出了下面的一段代码并给出了运 ...

  7. 程序猿的量化交易之路(29)--Cointrader之Tick实体(16)

    转载需注明出处:http://blog.csdn.net/minimicall,http://cloudtrade.top Tick:什么是Tick,在交易平台中很常见,事实上就 单笔交易时某仅仅证券 ...

  8. 关于Storm tick

    关于Storm tick 1. tick的功能 Apache Storm中内置了一种定时机制——tick,它能够让任何bolt的所有task每隔一段时间(精确到秒级,用户可以自定义)收到一个来自__s ...

  9. storm定时任务【tick】

    一. 简介      storm作为流计算,处理数据通常以数据驱动.即只有当spout发射数据才会进行计算.那么如果想要做定时任务如何处理哪,例如有的bolt需要输出一段时间统计的结果,这里一段时间可 ...

随机推荐

  1. HDU1215--七夕节

    找出小于N的全部因子的和,N比較大,非常明显要打表来做,不然肯定会超时 方法就是枚举范围内每一个整数.然后再枚举范围内这个整数的全部的倍数,加上这个数 由于这个整数的倍数中一定含有这个整数因子,这样速 ...

  2. 数学之路-python计算实战(21)-机器视觉-拉普拉斯线性滤波

    拉普拉斯线性滤波,.边缘检測  . When ksize == 1 , the Laplacian is computed by filtering the image with the follow ...

  3. Swift—使用try?和try!区别-仅供参考

    在使用try进行错误处理的时候,经常会看到try后面跟有问号(?)或感叹号(!),他们有什么区别呢? 1.使用try?  try?会将错误转换为可选值,当调用try?+函数或方法语句时候,如果函数或方 ...

  4. Delphi中处理URL编码解码

    Delphi中处理URL编码解码 一.URL简单介绍     URL是网页的地址,比方 http://www.shanhaiMy.com. Web 浏览器通过 URL 从 web server请求页面 ...

  5. HTML DOM createTextNode() 方法

    实例 创建一个文本节点: var btn=document.createTextNode("Hello World"); 输出结果: Hello World 尝试一下 » HTML ...

  6. 一起talk C栗子吧(第九十回:C语言实例--使用管道进行进程间通信三)

    各位看官们,大家好,上一回中咱们说的是使用管道进行进程间通信的样例.这一回咱们说的样例是:使用管道进行进程间通信.只是使用管道的方式不同样.闲话休提,言归正转.让我们一起talk C栗子吧! 我们在前 ...

  7. Analyzing with SonarScanner for MSBuild

    https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild Features The So ...

  8. tracert 路由跟踪程序

    C:\Users\Administrator>tracert 10.0.0.1 通过最多 30 个跃点跟踪到 10.0.0.1 的路由 1 <1 毫秒 1 ms 3 ms 192.168. ...

  9. 洛谷P3690 LCT模板

    题目:https://www.luogu.org/problemnew/show/P3690 自己竟然从没有钻研过LCT上的连通性问题! 于是被最后一个点卡了,似乎因为 find 函数只能找出连通性而 ...

  10. cisco secure ACS服务器搭建

    网上下载Cisco Secure Access Control System 5.2.iso的镜像,总共有两部分 http://pan.baidu.com/disk/home#path=%252FCi ...