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. 用yarn替代npm

    最近,从npm拉取vue-cli总失败,后来干脆直接用yarn 全局安装yarn(官网首推用系统包安装,更加安全) npm i yarn -g 用yarn添加全局vue-cli yarn global ...

  2. Python3标准库(二) re模块

    正则表达式(Regular Expression)是字符串处理的常用工具,通常被用来检索.替换那些符合某个模式(Pattern)的文本.很多程序设计语言都支持正则表达式,像Perl.Java.C/C+ ...

  3. bootstrap模态框出现或者消失的回调函数

    当某一模态框出现的时候就触发函数: $(".modal").on('show.bs.modal',function(){ if(vueObj){...}else{//如果vue对象 ...

  4. PHP数组去空项

    $strDelCodes = "A;B;;C;;C;D;;;D;D";$rsArray = array_values (array_unique (array_diff (spli ...

  5. Brackets常用插件

    Emmet插件:https://github.com/emmetio/brackets-emmet AngularJS插件:https://github.com/angular-ui/AngularJ ...

  6. Android 获取手机SIM卡运营商

    直接上代码: /** * 获取SIM卡运营商 * * @param context * @return */ public static String getOperators(Context con ...

  7. SepicalJudge

    原文:http://www.cnblogs.com/chouti/p/5752819.html Special Judge:当正确的输出结果不唯一的时候需要的自定义校验器 首先有个框架 #includ ...

  8. [疑问] C# 多线程程序,如果在并行程序块中开空间会远远慢于将空间开在并行块之外

    // int[,] label = new int[m, n]; Parallel.For(, thread_num, (n) => { ]; i++) { int[] tmp = new in ...

  9. 并不对劲的[Noi2008]道路设计

    Time Limit: 20 Sec Memory Limit: 162 MB Submit: 931 Solved: 509 [Submit][Status][Discuss] Descriptio ...

  10. ubuntu中 python升级 (转载)

    转自:http://blog.csdn.net/menglin8908/article/details/16822171 在ubuntu12.04中内置的python版本为2.7.3,最近想把pyth ...