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. js中 0.1+0.2 !== 0.3

    1. 存储原理: 在计算机中数字无论是定点数还是浮点数都是以多位二进制的方式进行存储的.事实上不仅仅是 Javascript,在很多语言中 0.1 + 0.2 都会得到 0.3000000000000 ...

  2. Educational Codeforces Round 60 D. Magic Gems

    易得递推式为f[i]=f[i-1]+f[i-M] 最终答案即为f[N]. 由于N很大,用矩阵快速幂求解. code: #include<bits/stdc++.h> using names ...

  3. 2-set奶牛议会

    Description 由于对Farmer John的领导感到极其不悦,奶牛们退出了农场,组建了奶牛议会.议会以“每头牛 都可以获得自己想要的”为原则,建立了下面的投票系统: M只到场的奶牛 (1 & ...

  4. 基于评分的商品top-N推荐系统

    import io # needed because of weird encoding of u.item file import os from surprise import KNNBaseli ...

  5. 怎么样使用vuex

    https://www.cnblogs.com/songrimin/p/7815850.html

  6. ElasticSearch及其插件安装配置

    elasticsearch安装使用 .安装步骤: 1.下载elasticsearch的rpm包: wget https://artifacts.elastic.co/downloads/elastic ...

  7. GitHub发卡系统zfaka配置历程

    GitHub发卡系统zfaka配置历程 1项目介绍 ​ ZFAKA发卡系统(本系统基于yaf+layui开发) ​ 项目地址 https://github.com/zlkbdotnet/zfaka 我 ...

  8. Redis客户端多线程跟多个连接不是一回事

    先抱怨一波,大国庆节的放假前一天的下班前15分钟,通知让我加班,因为一个Redis的bug,而这个bug我在1个半小时之前刚听说了个大概,心里很不情愿: 好了,说正事: 问题现象: bug是这样的,两 ...

  9. Fiddler is not capturing web request from Firefox

    Fiddler is not capturing web request from Firefox You can also get the FiddlerHook plug in for Firef ...

  10. linux工程管理软件—make

    一.make概述     make是一种代码维护工具make工具会根据makefile文件定义的规则和步骤,完成整个软件项目的代码维护工作.一般用来简化编译工作,可以极大地提高软件开发的效率. win ...