题意是说求出在一天中时针、分针、秒针之间距离均在 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",&deg))
{
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(时钟指针转角 **)的更多相关文章

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

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

  3. HDU 1006 Tick and Tick(时钟,分钟,秒钟角度问题)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1006 Tick and Tick Time Limit: 2000/1000 MS (Java/Oth ...

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

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

  5. HDU 5510---Bazinga(指针模拟)

    题目链接 http://acm.hdu.edu.cn/search.php?action=listproblem Problem Description Ladies and gentlemen, p ...

  6. hdu 1006 Tick and Tick 有技巧的暴力

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

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

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

  8. HDU 1006 模拟

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

  9. HDU 1006 Digital Roots

    Problem Description The digital root of a positive integer is found by summing the digits of the int ...

随机推荐

  1. XML中添加换行符

    网上说的说法大多是 可是我这里cuba框架用这个不是换行,下面这个才行 这也是转义字符, 为什么会是这样的?搞不懂,求大神告知! 另外 表示空格 表示回车

  2. 【hdu 6172】Array Challenge(数列、找规律)

    多校10 1002 HDU 6172 Array Challenge 题意 There's an array that is generated by following rule. \(h_0=2, ...

  3. poj3926 parade (单调队列+dp)

    题意:有n行路,每行路被分成m段,每一段有长度和权值,要求从最下面一行走到最上面一行某个位置,可以从相邻两行的同一列交点往上走,并且在同一行走的长度要<=K,求走过的最大权值 设f[i][j]为 ...

  4. Atlantis HDU - 1542 (扫描线,线段树)

    扫描线的模板题,先把信息接收,然后排序,记录下上边和下边,然后用一条虚拟的线从下往上扫.如果我扫到的是下边,那么久用线段树在这个区间内加上1,表示这个区间现在是有的,等我扫描到上边的时候在加上-1,把 ...

  5. Hyper-V:无法打开虚拟机XXX,因为虚拟机监控程序未运行

    异常处理汇总-服务器系列:http://www.cnblogs.com/dunitian/p/4522983.html 异常处理汇总-开发工具  http://www.cnblogs.com/duni ...

  6. Python学习day1 初识python&环境安装

    day1 环境安装-计算机基础 环境安装参见 https://blog.csdn.net/ling_mochen/article/details/79314118 1.markdown基本语法 htt ...

  7. 由AC自动机引发的灵感

    一,WA自动机 #include <cstdio> using namespace std; int main() { printf("☺"); ; } 二,TLE自动 ...

  8. vue2.0项目实战(1)基础入门

    最近公司的H5项目准备重构,部门老大说前端使用vue2.0来开发,所以就准备把整个项目的开发过程记录下来,一方面是为了记录开发过程中遇到的坑,另一方面也加强自己写作的能力. 什么是 Vue? 简要介绍 ...

  9. luogu2643 聪聪可可

    题目链接 题意 其实转化之后的题意就是求出树上有多少条路径长度是3的倍数.求答案的时候只要将这个数字除以总路径数量就行了. 思路 考虑点分治.对于当前子树,分别求出出树中每个点到根的路径长度对\(3\ ...

  10. Django 模板 继承和包含

    ##### 母版 ##### 这里是头部 {% block body-content %}{% endblock %} 这里是底部 #### 继承模板 ### {% extends 'layout.h ...