Tick and Tick

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19764    Accepted Submission(s):
5164

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
 
 
题解:直接就枚举就好了
 #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <cmath>
using namespace std;
double D;
double sum;
struct node
{
double l,r;
};
node ans[][];
node solve(double a,double b)
{
node qu;
if(a>)
{
qu.l=(D-b)/a;
qu.r=(-D-b)/a;
}
else
{
qu.l=(-D-b)/a;
qu.r=(D-b)/a;
}
if(qu.l<) qu.l=;
if(qu.r>) qu.r=;
if(qu.l>=qu.r) { qu.l=qu.r=;}
return qu;
}
node mer_g(node a,node b)
{
node q;
q.l=max(a.l,b.l);
q.r=min(a.r,b.r);
if(q.l>q.r) q.l=q.r=;
return q;
}
int main()
{
int h,m;
int i,j,k;
double a1,a2,a3,b1,b2,b3;
while(scanf("%lf",&D),D!=-)
{
sum=;
node qu;
for(h=;h<;h++)
for(m=;m<;m++)
{
b1=m*; a1=-5.9;
b2=*h+(0.5-)*m; a2=1.0/-0.1;
b3=*h+0.5*m; a3=1.0/-;
ans[][]=solve(a1,b1);ans[][]=solve(-a1,-b1);
ans[][]=solve(a2,b2);ans[][]=solve(-a2,-b2);
ans[][]=solve(a3,b3);ans[][]=solve(-a3,-b3);
for(i=;i<;i++)
for(j=;j<;j++)
for(k=;k<;k++)
{
qu=mer_g(mer_g(ans[][i],ans[][j]),ans[][k]);
sum+=qu.r-qu.l;
}
}
printf("%.3lf\n",sum*/);
}
return ;
}

hdu 1006 Tick and Tick的更多相关文章

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

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

  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. HDU 1006 Tick and Tick 解不等式解法

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

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

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

  9. 1006 Tick and Tick

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1006 题意: 24小时中,三个指针之间超过某个度数的时间占所有时间的百分比是多少. 思路:主要是物理和数学 ...

随机推荐

  1. PostgreSQL 学习手册-模式Schema

    一个数据库包含一个或多个命名的模式,模式又包含表.模式还包含其它命名的对象,包括数据类型.函数,以及操作符.同一个对象名可以在不同的模式里使用而不会导致冲突: 比如,schema1和myschema都 ...

  2. vue+大文件上传控件

    总结一下大文件分片上传和断点续传的问题.因为文件过大(比如1G以上),必须要考虑上传过程网络中断的情况.http的网络请求中本身就已经具备了分片上传功能,当传输的文件比较大时,http协议自动会将文件 ...

  3. CF369E Valera and Queries kdtree

    给你一堆线段,求:一个区间内包含的本质不同线段种类数(只要线段有一部分在区间中就算是包含) 考虑容斥:总线段数-被那些没有询问的区间完全覆盖的数量. 用离线+树状数组数点或者 KDtree 数点即可. ...

  4. Linux操作系统常用命令合集——第五篇-磁盘和文件系统操作(15个命令)

    1.fdisk [命令作用] 用于观察硬盘实体使用情况.也可以对硬盘分区. 对于一块硬盘来讲,最多只能管理15个分区 [命令语法]  fidisk    [选项]    [参数] [常用选项] -b& ...

  5. linux系列(十二):more命令

    1.命令格式: more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file] 2.命令功能: more命令和cat的功能一样都是查看文件里的内容,但 ...

  6. 控制层@Value注解取不到值

    @Value("${enable-upload-image}") private String enable; 如上所示,同样的代码,写在在业务层,运行时能取到正确的值,但在控制层 ...

  7. Java学习日记——基础篇(二)基本语法

    变量 变量和常量是程序处理的两种基本数据对象,变量是程序的基本组成单位 变量的目的就是确定目标并提供存放空间 public class Hello { public static void main( ...

  8. Hadoop hadoop的介绍和几种模式

    Hadoop简介 Hadoop软件库是一个开源框架,允许使用简单的编程模型跨计算机集群分布式处理大型数据集.它旨在从单个服务器扩展到数千台计算机,每台计算机都提供本地计算和存储.库本身不是依靠硬件来提 ...

  9. 手动制作BIOS和EFI多启动U盘

    原文链接:https://www.lainme.com/doku.php/blog/2017/07/%E5%88%B6%E4%BD%9Cbios%E5%92%8Cefi%E5%A4%9A%E5%90% ...

  10. commit 没有提交图片,但是出现了commit的修改

    .gitignore里面写上 image/cache/  就好了