Tick and Tick

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

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

计算出每两个指针满足要求的角度所需的时间,及周期,然后按周期循环。

#include<iostream>
#include<stdio.h>
using namespace std;
double max(double a,double b,double c)
{
double temp=(a>b)?a:b;
return (temp>c)?temp:c;
}
double min(double a,double b,double c)
{
double temp=(a<b)?a:b;
return (temp<c)?temp:c;
}
int main()
{
double wh=360.0//;
double wm=360.0//;
double ws=360.0/;
double whm=wm-wh;
double whs=ws-wh;
double wms=ws-wm;
//cout<<whm<<endl<<whs<<endl<<wms<<endl;
double n;
while(~scanf("%lf",&n)&&n!=-)
{
double stahm=n/whm;
double stahs=n/whs;
double stams=n/wms;
double endhm=(-n)/whm;
double endhs=(-n)/whs;
double endms=(-n)/wms;
double shm,shs,sms,ehm,ehs,ems;
const double T_hm=43200.0/,T_hs=43200.0/,T_ms=3600.0/; //Ïà¶ÔÖÜÆÚ
double sum=;
//cout<<"do"<<endl;
for(shm=stahm,ehm=endhm; ehm<43200.000001; shm+=T_hm,ehm+=T_hm)
{
//cout<<shm<<endl;
for(shs=stahs,ehs=endhs; ehs<43200.000001; shs+=T_hs,ehs+=T_hs)
{
if(ehm<shs) break;
if(shm>ehs) continue;
for(sms=stams,ems=endms; ems<43200.000001; sms+=T_ms,ems+=T_ms)
{
if(ehm<sms||ehs<sms) break;
if(shm>ems||shs>ems) continue;
//cout<<"doing"<<endl;
double xsta=max(shm,shs,sms);
double xend=min(ehm,ehs,ems);
if(xsta<xend)
sum+=(xend-xsta); }
}
}
printf("%.3lf\n",sum/); }
return ;
}

hdu 1006 Tick and Tick 有技巧的暴力的更多相关文章

  1. HDU 1006 Tick and Tick(时钟,分钟,秒钟角度问题)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1006 Tick and Tick Time Limit: 2000/1000 MS (Java/Oth ...

  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. hdu1006 Tick and Tick

    原题链接 Tick and Tick 题意 计算时针.分针.秒针24小时之内三个指针之间相差大于等于n度一天内所占百分比. 思路 每隔12小时时针.分针.秒针全部指向0,那么只需要计算12小时内的百分 ...

  5. HDU 1006 模拟

    Tick and Tick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. HDU 5908 Abelian Period (BestCoder Round #88 模拟+暴力)

    HDU 5908 Abelian Period (BestCoder Round #88 模拟+暴力) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=59 ...

  7. HDU 1006 [Tick Tick]时钟问题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1006 题目大意:钟表有时.分.秒3根指针.当任意两根指针间夹角大于等于n°时,就说他们是happy的, ...

  8. HDU 1006 Tick and Tick 解不等式解法

    一開始思考的时候认为好难的题目,由于感觉非常多情况.不知道从何入手. 想通了就不难了. 能够转化为一个利用速度建立不等式.然后解不等式的问题. 建立速度,路程,时间的模型例如以下: /******** ...

  9. [ACM_模拟] HDU 1006 Tick and Tick [时钟间隔角度问题]

    Problem Description The three hands of the clock are rotating every second and meeting each other ma ...

随机推荐

  1. C#使用DirectShow播放视频文件 [转]

    原文网址:http://blog.csdn.net/openzpc/article/details/48442751 最近在开发一个视频播放软件,主要要求就是循环播放多个视频文件,并且要求两个视频文件 ...

  2. ECharts学习总结(二):标签式单文件引入echarts的方法

    下载好echarts的库文件.然后在script里面引入. //from echarts example <body> <div id="main" style= ...

  3. Android WebView File域同源策略绕过漏洞浅析

       0x00     我们首先讲一个webView这种方法的作用: webView.getSettings().setAllowFileAccessFromFileURLs(false);     ...

  4. 转: SSH 公钥认证

    转: http://blog.knownsec.com/2012/05/ssh-%E5%85%AC%E9%92%A5%E8%AE%A4%E8%AF%81/ SSH 公钥认证 2012-05-15 简介 ...

  5. [ES6] 05. The leg keyword -- 3. Block Scope

    In ES6, IIFE is not necessary: // IIFE写法 (function () { var tmp = ...; ... }()); // 块级作用域写法 { let tm ...

  6. C#返回多个参数 ref及out

    out 关键字会导致参数通过引用来传递.这与 ref 关键字类似,不同之处在于 ref 要求变量必须在传递之前进行初始化.若要使用 out 参数,方法定义和调用方法都必须显式使用 out 关键字.例如 ...

  7. IDEA20181.4破解

    1.下载破解补丁: http://idea.lanyus.com/jar/JetbrainsIdesCrack-4.2-release-sha1-3323d5d0b82e716609808090d3d ...

  8. python------@staticmethod和@classmethod的作用与区别

    一般来说,要使用某个类的方法,需要先实例化一个对象再调用方法. 而使用@staticmethod或@classmethod,就可以不需要实例化,直接类名.方法名()来调用. 这有利于组织代码,把某些应 ...

  9. vim 查找和替换命令 替换/n和\n

    一. 字符串的查找 1. vim 中用 / 和 ? 来查找字符串,两者的区别是: /string 会高亮显示光标后匹配的第一个字符串,回车后光标移到该字符串的第一个字母: ?string 会高亮显示光 ...

  10. 通讯录结构体方法的实现 和VS中存在的一些问题的分析

    实现一个通讯录: 通讯录能够用来存储1000个人的信息.每一个人的信息包含: 姓名.性别.年龄.电话.住址 功能例如以下: 1.  加入联系人信息 2.  删除指定联系人信息 3.  查找指定联系人信 ...