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. 十五.DNS子域授权、分离解析、缓存DNS服务器

    1.搭建基本DNS服务器 pc7: 1.1 安装软件包 ]# yum -y install bind-chroot bind bind         //域名服务包 bind-chroot  //提 ...

  2. 使用webuploader实现断点续传

    核心原理: 该项目核心就是文件分块上传.前后端要高度配合,需要双方约定好一些数据,才能完成大文件分块,我们在项目中要重点解决的以下问题. * 如何分片: * 如何合成一个文件: * 中断了从哪个分片开 ...

  3. leetcode解题报告(22):Two Sum II - Input array is sorted

    描述 Given an array of integers that is already sorted in ascending order, find two numbers such that ...

  4. luogu P2018 消息传递

    二次联通门 : luogu P2018 消息传递 /* luogu P2018 消息传递 树形dp 原来用优先队列做了一下, T了俩点 MMP 去看正解.. 复杂度一样好不好.. 每次到达一个点,记录 ...

  5. express中的中间件(middleware)、自定义中间件、静态文件中间件、路由中间件

    express文档地址 什么是中间件呢(middleware)?它是谁的中间件呢? 首先我们需要了解到请求和响应, 请求就是客户端发送请求给服务器, 响应就是,服务器根据客户端的请求返回给客户端的数据 ...

  6. win10下交换CapLock和Esc按键

    win10下使用vim编辑时,需频繁用Esc键,可是Esc键在键盘左上角,位置遥远,操作不便.可以CapsLock键处在黄金位置,但是几乎无用,看过键盘发展历史,其实是是在发展过程中的意外而已,将两键 ...

  7. linux的free命令详解-内存是拿来用的不是拿来看的

    $ free -m total used free shared buffers cached Mem: -/+ buffers/cache: Swap: 第一部分Mem行:total 内存总数: 1 ...

  8. Java类的变量初始化顺序

    大家在去参加面试的时候,经常会遇到这样的考题:给你两个类的代码,它们之间是继承的关系,每个类里只有构造器方法和一些变量,构造器里可能还有一段代码对变量值进行了某种运算,另外还有一些将变量值输出到控制台 ...

  9. Flutter移动电商实战 --(45)详细页_说明区域UI编写

    pages/details_page/details_expain.dart 详情页面引用组件 效果展示: 最终代码: import 'package:flutter/material.dart'; ...

  10. raid卷性能测试

    #RAID卷 独立磁盘冗余阵列RAID是一种把多块独立的硬盘(物理硬盘)按不同的方式组合起来形成一个硬盘组(逻辑硬盘),从而提供比单个硬盘更高的存储性能和提供数据备份技术.组成磁盘阵列的不同方式成为R ...