HDU 1006(时钟指针转角 **)
题意是说求出在一天中时针、分针、秒针之间距离均在 D 度以上的时间占比。
由于三针始终都在转动,所以要分别求出各个针之间的相对角速度,分别求出三针满足角度差的首次时间,再分别求出不满足角度差的最终时间,取这三个时间段的交集,也就是首次时间的最大值和最终时间的最小值之间的部分,要注意剪枝,去掉多余的部分,否则会超时的,
本人的代码也是借鉴了别人写出来的。代码如下:
#include <bits/stdc++.h>
using namespace std;
const double hm = 11.0/;//时针分针相对角速度hm = m - h = 360/3600 - 360/(12*3600) = 11/120
const double hs = 719.0/;//时针秒针相对角速度hs = s - h = 360/60 - 360/(12*3600) = 719/120
const double ms = 59.0/;//分针秒针相对角速度ms = s - m = 360/60 - 360/3600 = 59/10
const double thm = 43200.0/;//thm = 360/hm = 43200/11
const double ths = 43200.0/;//ths = 360/hs = 43200/719
const double tms = 3600.0/;//tms = 360/ms = 3600/59
const double eps = 1e-;
double max(double a,double b,double c)
{
if(a>b) return a>c?a:c;
return b>c?b:c;
}
double min(double a,double b,double c)
{
if(a<b) return a<c?a:c;
return b<c?b:c;
}
int main()
{
int deg;
double from1,from2,from3,to1,to2,to3,x1,x2,x3,y1,y2,y3,st,ed,ans;
while(scanf("%d",°))
{
if(deg==-) break;
from1 = deg/hm;
from2 = deg/hs;
from3 = deg/ms;
to1 = (-deg)/hm;
to2 = (-deg)/hs;
to3 = (-deg)/ms;
ans = 0.0;
for(x1 = from1, y1 = to1; y1 <= +eps; x1+=thm, y1+=thm)
for(x2 = from2, y2 = to2; y2 <= +eps; x2+=ths, y2+=ths)
{
if(x2>y1) break;
for(x3 = from3, y3 = to3; y3 <= +eps; x3+=tms, y3+=tms)
{
if(x3>y1 || x3>y2) break;
st = max(x1,x2,x3);
ed = min(y1,y2,y3);
if(st<ed) ans+=ed-st;
}
}
printf("%.3lf\n",ans*100.0/);//求出时间和的占比
}
return ;
}
HDU 1006(时钟指针转角 **)的更多相关文章
- HDU 1006 Tick and Tick 时钟指针问题
Tick and Tick Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1006 [Tick Tick]时钟问题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1006 题目大意:钟表有时.分.秒3根指针.当任意两根指针间夹角大于等于n°时,就说他们是happy的, ...
- HDU 1006 Tick and Tick(时钟,分钟,秒钟角度问题)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1006 Tick and Tick Time Limit: 2000/1000 MS (Java/Oth ...
- [ACM_模拟] HDU 1006 Tick and Tick [时钟间隔角度问题]
Problem Description The three hands of the clock are rotating every second and meeting each other ma ...
- HDU 5510---Bazinga(指针模拟)
题目链接 http://acm.hdu.edu.cn/search.php?action=listproblem Problem Description Ladies and gentlemen, p ...
- hdu 1006 Tick and Tick 有技巧的暴力
Tick and Tick Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1006 Tick and Tick 解不等式解法
一開始思考的时候认为好难的题目,由于感觉非常多情况.不知道从何入手. 想通了就不难了. 能够转化为一个利用速度建立不等式.然后解不等式的问题. 建立速度,路程,时间的模型例如以下: /******** ...
- HDU 1006 模拟
Tick and Tick Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1006 Digital Roots
Problem Description The digital root of a positive integer is found by summing the digits of the int ...
随机推荐
- Git回滚代码暴力法
Git回滚有多种方式,这里使用的是[强制提交到远程分支] 效果为:如回滚前的提交记录是 1.2.3.4,使用这种方法回滚到2,那么提交记录就变成了1.2. 操作方法: 需要在本地的Git仓库,右键选择 ...
- Linux block(1k) block(4k) 换算 gb
输入 df 显示1k blocks 大小 再输入 df -h 显示 gb换算大小 结论 block(1k) 计算公式为: block(1k) /1024/1000 = xx gb ...
- JVM垃圾收集(Java Garbage Collection / Java GC)
JVM垃圾收集(Java Garbage Collection / Java GC) Java7 Java8 JDK1.8之后将最初的永久代取消了,由元空间取代. 堆内存调优简介 public sta ...
- 【BZOJ5332】[SDOI2018]旧试题(数论,三元环计数)
[BZOJ5332][SDOI2018]旧试题(数论,三元环计数) 题面 BZOJ 洛谷 题解 如果只有一个\(\sum\),那么我们可以枚举每个答案的出现次数. 首先约数个数这个东西很不爽,就搞一搞 ...
- Nginx+Tomcat-cluster构建
-----------ReProxy-------------------------Client-----------192.168.56.202 nginx 192.168.56.200 Tomc ...
- python 逻辑运算符问题
1 正确 if('A' not in self.storageDevice.softVersion or\ 'B' not in self.storageDevice.softVersion or\ ...
- Ability
Base:网络安全,sklearn(ML),日本語,企业存储 Branch1:自动化,Git Branch2:HW系统架构 Branch3:shadowsocks源码:
- 【转】top命令输出解释以及load average 详解及排查思路
https://blog.csdn.net/zhangchenglikecc/article/details/52103737 昨天nagios报警warning,没来得及留下报警截图,nagios值 ...
- 为什么分布式一定要有redis?
为什么分布式一定要有redis? 孤独烟 架构师小秘圈 昨天 作者:孤独烟 来自:http://rjzheng.cnblogs.com/ 1.为什么使用redis 分析:博主觉得在项目中使用red ...
- MAC安装JDK及环境变量配置
1.访问Oracle官网 http://www.oracle.com,浏览到首页的底部菜单 ,然后按下图提示操作: 2.点击“JDK DOWNLOAD”按钮: 3.选择“Accept Lisence ...