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. 如何高效的将excel导入sqlserver?

    大部分人都知道用oledb来读取数据到dataset,但是读取之后怎么处理dataset就千奇百怪了.很多人通过循环来拼接sql,这样做不但容易出错而且效率低下,System.Data.SqlClie ...

  2. Node.js:Web模块、文件系统

    一.web模块 Web服务器一般指网站服务器,是指驻留于因特网上某种类型计算机的程序,Web服务器的基本功能就是提供Web信息浏览服务.它只需支持HTTP协议.HTML文档格式及URL,与客户端的网络 ...

  3. PHP实现双向链表、栈

    前期写过一个PHP实现单向链表.实现排序单向链表的一篇文章,传送门:http://www.cnblogs.com/yydcdut/p/3777760.html.双向链表写过了,再拿出来提一提:http ...

  4. python 相似语句匹配(非机器学习)

    #coding=utf-8 import xlrd import distance from sklearn.feature_extraction.text import CountVectorize ...

  5. linux下vim命令具体解释

    很具体的介绍linux中vim的操作命令. 高级一些的编辑器,都会包括宏功能,vim当然不能缺少了.在vim中使用宏是很方便的: :qx     開始记录宏.并将结果存入寄存器x q     退出记录 ...

  6. Struts完美解决i18n问题

    所谓的i18n问题指的是(软件的)国际化问题,简单来讲就是使我们的软件可以让世界使用任何语言的人们都能使用,软件自身会根据语言环境的不同进行自动配置,如果你是中文环境那界面以中文显示,如果是英文环境就 ...

  7. 总结一些js自定义的函数

    1.dayin() 作用:将id为dayin的内容,新建页面并打印,可解决打印某页面中的部分内容的问题. 使用方法:将要打印的内容通过 <span id="dayin"> ...

  8. 用lambda表达式树替代反射

    本节重点不讲反射机制,而是讲lambda表达式树来替代反射中常用的获取属性和方法,来达到相同的效果但却比反射高效. 每个人都知道,用反射调用一个方法或者对属性执行SetValue和GetValue操作 ...

  9. 工作总结 @{var sas = String.Format("{0:yyyy-MM-dd}", Model.DemandTime.GetValueOrDefault());}

      可空DateTime类型 无法Tostring 或者 格式化时间格式   需要转换 为DateTime Nullable<T>.GetValueOrDefault() 方法 返回对应的 ...

  10. EntityFramework Data Annotations

    详细的实体映射介绍(Data Annotation) http://msdn.microsoft.com/en-us/data/jj591583