hdu 1006 Tick and Tick
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
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.
single line with a real number D between 0 and 120, inclusively. The input is
terminated with a D of -1.
time in a day that all of the hands are happy, accurate up to 3 decimal
places.
120
90
-1
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的更多相关文章
- HDU 1006 Tick and Tick(时钟,分钟,秒钟角度问题)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1006 Tick and Tick Time Limit: 2000/1000 MS (Java/Oth ...
- HDU 1006 Tick and Tick 时钟指针问题
Tick and Tick Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- hdu 1006 Tick and Tick 有技巧的暴力
Tick and Tick Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- hdu1006 Tick and Tick
原题链接 Tick and Tick 题意 计算时针.分针.秒针24小时之内三个指针之间相差大于等于n度一天内所占百分比. 思路 每隔12小时时针.分针.秒针全部指向0,那么只需要计算12小时内的百分 ...
- HDU 1006 模拟
Tick and Tick Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1006 [Tick Tick]时钟问题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1006 题目大意:钟表有时.分.秒3根指针.当任意两根指针间夹角大于等于n°时,就说他们是happy的, ...
- HDU 1006 Tick and Tick 解不等式解法
一開始思考的时候认为好难的题目,由于感觉非常多情况.不知道从何入手. 想通了就不难了. 能够转化为一个利用速度建立不等式.然后解不等式的问题. 建立速度,路程,时间的模型例如以下: /******** ...
- [ACM_模拟] HDU 1006 Tick and Tick [时钟间隔角度问题]
Problem Description The three hands of the clock are rotating every second and meeting each other ma ...
- 1006 Tick and Tick
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1006 题意: 24小时中,三个指针之间超过某个度数的时间占所有时间的百分比是多少. 思路:主要是物理和数学 ...
随机推荐
- 062_判断用户输入的是 Yes 或 NO
#!/bin/bashread -p "Are you sure?[y/n]:" surecase $sure iny|Y|Yes|YES) echo "you ...
- Mac 安装软件时,提示已损坏解决
"xxx.app已损坏,打不开.你应该将它移到废纸篓",并非你安装的软件已损坏,而是Mac系统的安全设置问题,因为这些应用都是破解或者汉化的,那么解决方法就是临时改变Mac系统安全 ...
- JS中的常用的代码操作
本文件介绍常用的js代码的DOM操作.CSS操作.对象(Object对象.Array对象.Number对象.String对象.Math对象.JSON对象和Console对象)操作说明. 一.DOM树的 ...
- OAuth 2.0 的四种方式
上一篇文章介绍了 OAuth 2.0 是一种授权机制,主要用来颁发令牌(token).本文接着介绍颁发令牌的实务操作. 下面我假定,你已经理解了 OAuth 2.0 的含义和设计思想,否则请先阅读这个 ...
- 阿里云服务器发送邮件:Connection could not be established with host smtp.qq.com [Connection timed out #110]
阿里云服务器发送邮件:Connection could not be established with host smtp.qq.com [Connection timed out #110] 一.总 ...
- linux物理内存与虚拟内存
http://www.360doc.com/content/14/0123/14/14450281_347336709.shtml 1.查看内存占用情况 $ free -m -h total used ...
- c3p0数据库连接池 原创: Java之行 Java之行 5月8日 一、连接池概述 实际开发中“获得连接”或“释放资源”是非常消耗系统资源的两个过程
c3p0数据库连接池 原创: Java之行 Java之行 5月8日 一.连接池概述 实际开发中“获得连接”或“释放资源”是非常消耗系统资源的两个过程 DB连接池HikariCP为什么如此快 原创: D ...
- Docs-.NET-C#-指南-语言参考-预处理器指令:#warning(C# 参考)
ylbtech-Docs-.NET-C#-指南-语言参考-预处理器指令:#warning(C# 参考) 1.返回顶部 1. #warning(C# 参考) 2015/07/20 #warning 允许 ...
- SSH工具登录远程指定节点时输入用户名密码方式【我】
通过堡垒机部署项目, 一种方式:先把补丁传到接入机,然后用CRT等命令行工具登录指定接入机,然后用SCP命令把 补丁传到 生产服务器,比如 scp -P90010 /app/backup/packet ...
- Spring走向注解驱动编程
SpringFramework的两大核心,IOC(Inversion of control)控制反转和DI(Dependency Inject)依赖注入,其推崇的理念是应用系统不应以java代码的方式 ...