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. WEB渗透之对于开了3389远程连接不上的总结

    对于开了3389,连接不上,有几个方面的原因,我来总结下,哇咔咔,这几天提好几台服务器都TM这样,分析下, 原因1.远程桌面端口被更改.2.对方服务器处于内网. 3.防火墙拦截.4.TCP/IP安全限 ...

  2. datanode无法启动问题

    在执行了hdfs namenode -format命令之后,再启动datanode发现无法启动. 查看datanode的日志发现: datanode的ClusterId和namenode的Cluste ...

  3. Android面试,BroadCastReceiver的两种注册方式的异同

    在Android手机应用程序中开发中,需要用到BroadcastReceiver来监听广播的消息.在自定义好BroadcastReceiver ,需要对其进行注册,注册有两种方法: 一种是在代码当中注 ...

  4. 浅谈PHP数据结构之栈

    今天開始进阶自己的PHP,首先一切的编程语言都须要修炼自己的"内功",何为程序猿的"内功",我想大概就是数据结构和算法了吧 .毕竟是灵魂,是普通程序猿到高级程序 ...

  5. 微信小程序 - 贝塞尔曲线(购物车效果)

    转载来源于:https://segmentfault.com/a/1190000011710786 简化了一下,发出来吧 示例源码:点击下载

  6. activeMQ消费消息时网络流量异常大的问题

    http://www.cnblogs.com/baibaluo/archive/2012/12/24/2748468.html#2590289 公司有一个应用,多个线程从activeMQ中取消息,随着 ...

  7. Selenium中定位元素的方法

    find_element_by_id()find_element_by_name()find_element_by_class_name()find_element_by_tag_name()find ...

  8. Tetris

    he Tetris game is one of the most popular computer games ever created. The original game was designe ...

  9. 【Linux】od命令

    用途 od命令主要用于查看非文本文件,通过指定该命令的不同选项可以以十进制.八进制.十六进制和ASCII码来显示 全称 od的全称为:Octal Dump 参数 -t :后面接各种类型的显示方式 a ...

  10. Spring NamedParameterJdbcTemplate详解

    NamedParameterJdbcTemplate和JdbcTemplate功能基本差不多.使用方法也类型.下面具体看下代码. db.properties jdbc.user=root jdbc.p ...