题意是说求出在一天中时针、分针、秒针之间距离均在 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. mysql 导入sql 2006 - mysql server has gone away 导入

    解决办法:找到你的mysql目录下的my.ini配置文件,加入以下代码 max_allowed_packet=500M wait_timeout=288000 interactive_timeout ...

  2. 【Luogu2197】NIM游戏(博弈论)

    题面 洛谷 题解 \(Nim\)游戏模板题 #include<iostream> #include<cstdio> #include<cstdlib> using ...

  3. [SNOI2017]一个简单的询问【莫队+容斥原理】

    题目大意 给你一个数列,让你求两个区间内各个数出现次数的乘积的和. 分析 数据范围告诉我们可以用莫队过. 我并不知道什么曼哈顿什么乱七八糟的东西,但是我们可以用容斥原理将这个式子展开来. \[\sum ...

  4. mac上安装ta-lib

    Now I am ready to start installing TA-Lib. Generally I followed the steps listed in here. 1. Install ...

  5. 使用 sizeof 获取字符串数组的大小

    @2018-11-1 字符串组成的数组存放于指针数组中,使用 sizeof 获取数组大小 [验证] #include <stdio.h> #define BootScreen " ...

  6. photoshop学习4

    蒙版 路径学习 一.蒙版 蒙版可以理解为一层在图层上的遮挡布,为什么要将图层遮住呢,有什么好处.好处在于容易编辑. 在一个图层上建立一个蒙版之后,可以用再删掉不需要的部分,从而露出原图层的部分.那么这 ...

  7. Nginx+Tomcat-cluster构建

    -----------ReProxy-------------------------Client-----------192.168.56.202 nginx 192.168.56.200 Tomc ...

  8. MYSQL主从复制制作配置方案

    1. 主从复制机器配置 操作系统:centos7 x64 基于vagrant下的virtual box的虚拟机两台 master ip:192.168.21.11, slave ip 192.168. ...

  9. BZOJ 1996: [Hnoi2010]chorus 合唱队(区间dp)

    题目: https://www.lydsy.com/JudgeOnline/problem.php?id=1996 题解: 这题刚拿到手的时候一脸懵逼qwq,经过思考与分析(看题解),发现是一道区间d ...

  10. apt could not get lock

    很多次遇到,就是记不住. sudo rm /var/cache/apt/archives/lock sudo rm /var/lib/dpkg/lock sudo rm /var/lib/apt/li ...