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. Power Desginer系列03【转载】

    在PowerDesigner中设计物理模型1——表和主外键 在PD中建立物理模型由以下几种办法: 直接新建物理模型. 设计好概念模型,然后由概念模型生成物理模型. 设计好逻辑模型,然后由逻辑模型生成物 ...

  2. Install Python+Django+Nginx+UWSGI

    一.软件环境: CentOS6.6_64bit 需要用到的软件: [root@django tools]# ll 总用量 33336 -rw-r--r-- 1 root root 7497785 3月 ...

  3. c# 注册表操作,创建,删除,修改,判断节点是否存在

    用.NET下托管语言C#操作注册表,主要内容包括:注册表项的创建,打开与删除.键值的创建(设置值.修改),读取和 删除.判断注册表项是否存在.判断键值是否存在. 准备工作: 1:要操作注册表,我们必须 ...

  4. Node.js:Buffer(缓冲区)介绍及常用方法

    JavaScript 语言自身只有字符串数据类型,没有二进制数据类型. 但在处理像TCP流或文件流时,必须使用到二进制数据.因此在 Node.js中,定义了一个 Buffer 类,该类用来创建一个专门 ...

  5. Cocos2d-X中的动作特效

    Cocos2d-X中提供了很丰富的动作特效 比如:网格动画 扭曲特效 3D瓷砖波动特效 程序代码: #include "ActionEffect.h" #include " ...

  6. 【Python】Django filter 如何支持 or 条件过滤?

    from django.db.models import Q Item.objects.filter(Q(creator=owner) | Q(moderated=False)) 代码示例: if(r ...

  7. PHP RESTful

    PHP RESTful REST(英文:Representational State Transfer,简称REST) ,指的是一组架构约束条件和原则. 符合REST设计风格的Web API称为RES ...

  8. Python 多重循环

    # coding=gbk LOL1 = ['OMG', 'EDG', '皇族'] LOL2 = ['韩国', '欧洲', '美国'] for l1 in LOL1: for l2 in LOL2: p ...

  9. ant design pro(一)安装、目录结构、项目加载启动【原始、以及idea开发】

    一.概述 1.1.脚手架概念 编程领域中的“脚手架(Scaffolding)”指的是能够快速搭建项目“骨架”的一类工具.例如大多数的React项目都有src,public,webpack配置文件等等, ...

  10. windows bat文件运行中文乱码

      windows bat文件运行中文乱码 CreationTime--2018年7月17日08点51分 Author:Marydon 1.情景展示 运行bat文件,里面的中文提示显示乱码 2.问题剖 ...