传送门:

http://acm.hdu.edu.cn/showproblem.php?pid=1006

Tick and Tick

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

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
 
题意:时针,分针和秒针都厌倦了其余两针,只有在与其余两针保持n度以上的距离才能感到高兴。问一天中,三针都高兴的时间占总时间的百分比。注意时间是连续的。
 
分析:
时间是连续的,不能枚举。。我一开始就去枚举。。。
推荐一个大神的题解:(我的太垃圾)
不要脸的贴一下代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define max_v 10000
int main()
{
int t;
double n,sum,ft1,ft2,ft3,et1,et2,et3,max,min;
double sm,sh,mh,tsm,tsh,tmh,fsm,fsh,fmh,esm,esh,emh;
sm=./.;
sh=./.;
mh=./.;
tsm=*sm;
tsh=*sh;
tmh=*mh;
while(~scanf("%lf",&n))
{
if(n<)
break;
sum=;
fsm=sm*n;
fsh=sh*n;
fmh=mh*n;
esm=tsm-fsm;
esh=tsh-fsh;
emh=tmh-fmh;
for(ft3=fmh,et3=emh;et3<=;et3+=tmh,ft3+=tmh)
{
for(ft2=fsh,et2=esh;et2<=;et2+=tsh,ft2+=tsh)
{
if(et2<ft3)
continue;
if(ft2>et3)
break;
for(t=,ft1=fsm,et1=esm;et1<=;t=t+,et1=esm+t*tsm,ft1=fsm+t*tsm)
{
if(et1<ft3 || et1<ft2)
continue;
if(ft1>et3 || ft1>et2)
break;
max=ft1;
if(ft2>max)
max=ft2;
if(ft3>max)
max=ft3;
min=et1;
if(et2<min)
min=et2;
if(et3<min)
min=et3;
sum+=min-max;
}
}
}
sum/=.;
printf("%.3lf\n",sum);
}
return ;
}
 

HDU 1006 Tick and Tick(时钟,分钟,秒钟角度问题)的更多相关文章

  1. HDU 1006 Tick and Tick 时钟指针问题

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

  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 1006 [Tick Tick]时钟问题

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

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

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

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

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

  9. 1006 Tick and Tick

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1006 题意: 24小时中,三个指针之间超过某个度数的时间占所有时间的百分比是多少. 思路:主要是物理和数学 ...

随机推荐

  1. Linux常用指令整理

    Linux常用命令整理 快捷键 [Tab] [Tab] 接在一串指令的第一个字的后面,则为"命令补全": [Tab] 接在一串指令的第二个字以后时,则为"文件补齐&quo ...

  2. 三 Buffer

    使用Buffer一般遵循以下四个步骤 写入数据到Buffer 调用flip() 从Buffer中读取数据 调用clear()或者compact()方法 当向buffer写入数据时,buffer会记录下 ...

  3. PHP框架中.htaccess文件作用

    1..htaccess文件使用前提 .htaccess的主要作用就是实现url改写,也就是当浏览器通过url访问到服务器某个文件夹时,作为主人,我们可以来接待这个url,具体地怎样接待它,就是此文件的 ...

  4. svg基础知识体系建立

    一.简介:SVG 是使用 XML 来描述二维图形和绘图程序的语言. SVG 指可伸缩矢量图形 (Scalable Vector Graphics) SVG 用来定义用于网络的基于矢量的图形 SVG 使 ...

  5. crontab 切割日志

    cutlog.sh #!/bin/sh source /etc/profile D=$(date "+%Y%m%d%H%M%S") mv "/usr/local/Cell ...

  6. java.util.concurrent.Semaphore 使用

    1. 概述 Semaphore(信号)  并不存在真正的许可 只是维护一个计数器, 通常用来限定进入一些资源的线程数 accquire()  方法获取许可 成功则计数器值-1 没有则阻塞直到一个可用的 ...

  7. js权威指南学习笔记(一)类型、值和变量

    1.数据类型:原始类型(primitive type) 和对象类型(object type) 原始类型包括数字.字符串和布尔值: 除数字.字符串.布尔值.null(空).undefined(未定义), ...

  8. div 居中方法汇总

    本文是从简书复制的, markdown语法可能有些出入, 想看"正版"和更多内容请关注 简书: 小贤笔记 情况一: 父子容器宽高已知 方法一 html <div class= ...

  9. 小Y的轮回之路——攒机装机、B150装win7

    两个月前,陪伴我5年多的小Y(ideapad-y460N卡)突然大伤元气,硬盘跪了,显示屏也黑了一小块.本着经济实惠凑合用的态度换了个320G的硬盘,没想过几天显示屏情况加重,出现无数个红绿相间的线条 ...

  10. UVaOJ 694 - The Collatz Sequence

    题目很简单,但是一开始却得到了Time Limit的结果,让人感到很诧异.仔细阅读发现,题目中有一个说明: Neither of these, A or L, is larger than 2,147 ...