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 ... 
随机推荐
- windows 系统错误码总结
			windows 错误码大全: 操作成功完成. 功能错误. 系统找不到指定的文件. 系统找不到指定的路径. 系统无法打开文件. 拒绝访问. 句柄无效. 存储控制块被损坏. 存储空间不足,无法处理此命令. ... 
- flask报错:werkzeug.routing.BuildError: Could not build url for endpoint 'index'. Did you mean 'single' instead?
			错误代码 参考:https://blog.csdn.net/qq_27468251/article/details/81359701 改为 
- 自学Python4.4-装饰器的进阶
			自学Python之路-Python基础+模块+面向对象自学Python之路-Python网络编程自学Python之路-Python并发编程+数据库+前端自学Python之路-django 自学Pyth ... 
- [leetcode]Weekly Contest 68 (767. Reorganize String&&769. Max Chunks To Make Sorted&&768. Max Chunks To Make Sorted II)
			766. Toeplitz Matrix 第一题不说,贼麻瓜,好久没以比赛的状态写题,这个题浪费了快40分钟,我真是...... 767. Reorganize String 就是给你一个字符串,能不 ... 
- luogu3953 [NOIp2017]逛公园 (tarjan+dijkstra+记忆化搜索)
			先跑一边dijkstra算出从1到i的最短距离dis[i] 然后建反向边 从n开始记忆化搜索,(p,k)表示1到p的距离=dis[p]+k的方案数 答案就是$\sum\limits_{i=0}^{k} ... 
- Freescale 车身控制模块(BCM) 解决方案
			中国汽车业已成为全球第一市场,标志着中国汽车产业进入了白热化竞争时代,因此,人们对汽车的操控性,安全性,易用性,舒适性,以及智能化要求也越来越高,更大的空间需求和更多的零部件因而产生了冲突,这就要求汽 ... 
- 初入react-redux  (基于webpack babel的react应用框架)
			react这么热门的框架也不介绍了,redux是一个单项数据流的小框架,当然不只配合react,它起初是为react而配的,现在面向所有了,比如ng-redux的项目.redux做为react的标准搭 ... 
- staitc
			一.static和非static变量 1. static 修饰的变量称为类变量或全局变量或成员变量,在类被加载的时候成员变量即被初始化,与类关联,只要类存在,static变量就存在.非static修饰 ... 
- 洛谷P1399 快餐店
			题意:在基环树上找一点,使得这个点到所有点的距离最大值最小.这个点可以在某条边上. 解:很容易想到找出直径然后/2对吧...这里的直径是指任意两点间最短距离的最大值. 然而我这个SB冥思苦想了半天之后 ... 
- 浏览器直接显示html代码,不解析代码
			在某些时候,我们可能因为某些特殊的原因,不想让浏览器解析html代码. 1,把代码放到js中,如下 <script type='text/html' style='display:block'& ... 
