传送门:

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. sun.misc.unsafe

    Java中大部分错误都是基于内存管理方面的.如果想破坏,可以使用Unsafe这个类. 实例化Unsafe: 下面两种方式是不行的 private Unsafe() {} //私有构造方法 @Calle ...

  2. JBPM学习第4篇:10分钟熟悉Eclipse

    http://download.jboss.org/jbpm/videos/7.0.0.Final_eclipse_getting_started.swf 打开视频练习 1.导入 evaluation ...

  3. Hibernate 注解(Annotations 一)

    1. @Entity 将一个类声明为一个实体bean(即一个持久化POJO类). 2. @Table 声明了该实体bean映射指定的表(table),目录(catalog)和schema名字 3. @ ...

  4. C语言转置矩阵算法

    对一个nxn阶的矩阵进行转置,算法如下: #include <stdio.h> #define n 3 void MM(int a[][n]) { int i,j,temp; ;i < ...

  5. JSON中的安全问题

    Web中使用JSON时最常见的两个安全问题: 1.跨站请求伪造: 即CSRF,是一种利用站点对用户浏览器信任发起攻击的方式.典型的就是JSON数组,更多信息请自行上网百度. 2.跨站脚本攻击. 是注入 ...

  6. Quick Easy FTP Server FTP工具文件传输使用

    1 工具配置 2 linux 下ftp命令上传和下载文件到FTP_DIR目录 1 ftp 172.16.18.292 输入用户名3 输入密码 4 ls或dir 查看目录及文件  lcd进入本地目录  ...

  7. C# GDI+ 利用 Rectangle GraphicsPath 判断 矩形或多边形 图形关系

    最近在做一些简单的图像对比工作,总结了一些GDI+对象的使用方式,记录下来共享给大家使用. 判断Rectangl与多边形的关系 /// <summary> /// 是否包含输入范围 /// ...

  8. 【PHP系列】框架的抉择

    缘起 在PHP开发中,选择合适的框架有助于加快软件开发,节约宝贵的项目时间,让开发者专注于功能的实现上.框架的问题是需要很多的投入,选择框架时,我们更看重这个框架的未来,存在多年的大型框架必须要有好的 ...

  9. android测试Code

    <!--android:layout_alignParentTop="true"--><com.koooke.platform.View.CenterImage ...

  10. C#mail发送

    这里,简单封装一个函数来发送邮件,代码如下: /// <summary> /// 邮件发送辅助类 /// </summary> public class MailHelper ...