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. java json字符串转成 Map或List

    import java.util.List; import java.util.Map; import java.util.Map.Entry; import net.sf.json.JSONArra ...

  2. 【Android】使用 SwipeRefreshLayout 实现下拉刷新

    今天在codepath 上看到一个开源项目 [点击查看]使用到了 SwipeRefreshLayout 实现了下拉刷新,但演示样例并不完整,于是自己就动手写了下.之前看到郭霖的博客上也有介绍下拉刷新, ...

  3. 【poj2774】Long Long Message

    用个分隔符将两个字符串连接起来,再用后缀数组求出height数组的值,找出一个height值最大并且i与i-1的sa值分别在两串字符中就好 #include<algorithm> #inc ...

  4. ios23--动画做弹出提示框toast

    ) { /* [UIView animateWithDuration:2.0 animations:^{ // 执行动画 self.showHUB.text = @"当前购物车已空,赶紧买买 ...

  5. tyvj 1013 找啊找啊找GF

    题目大意: 有一个背包,里面的东西需要满足两个条件,不只是体积 求最多能装多少东西,这些东西的东西最小价值 思路: 双重背包 开两个数组,记录装的东西数量和价值 #include<iostrea ...

  6. CSYZDay1模拟题解

    T1.game [问题描述] LZK发明一个矩阵游戏,大家一起来玩玩吧,有一个N行M列的矩阵.第一行的数字是1,2,…M,第二行的数字是M+1,M+2…2*M,以此类推,第N行的数字是(N-1)*M+ ...

  7. Face alignment at 3000FPS via Regressing Local Binrary features 理解

    这篇是Ren Shaoqing发表在cvpr2014上的paper,论文是在CPR框架下做的,想了解CPR的同学可以参见我之前的博客,网上有同学给出了code,该code部分实现了LBF,链接为htt ...

  8. IDEA hadoop MapReduce 环境配置

    1.下载,安装,配置好Hadoop 2.在IDEA中执行MapReduc 配置: 这里将JAR包加入: JAR包是:/usr/local2/hadoop/share/hadoop 目录下:直接右边+以 ...

  9. Same Tree 序列化二叉树

    https://oj.leetcode.com/problems/same-tree/ Given two binary trees, write a function to check if the ...

  10. Kettle 连接 oracle 报错:could not be found, make sure the 'Oracle' driver (jar file) is installed.

    我的ETL版本为6.0 oracle版本为11.2.0 报错如下: Driver class 'oracle.jdbc.driver.OracleDriver' could not be found, ...