Tick and Tick

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

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
 
Author
PAN, Minghao
 
Source

计算出每两个指针满足要求的角度所需的时间,及周期,然后按周期循环。

#include<iostream>
#include<stdio.h>
using namespace std;
double max(double a,double b,double c)
{
double temp=(a>b)?a:b;
return (temp>c)?temp:c;
}
double min(double a,double b,double c)
{
double temp=(a<b)?a:b;
return (temp<c)?temp:c;
}
int main()
{
double wh=360.0//;
double wm=360.0//;
double ws=360.0/;
double whm=wm-wh;
double whs=ws-wh;
double wms=ws-wm;
//cout<<whm<<endl<<whs<<endl<<wms<<endl;
double n;
while(~scanf("%lf",&n)&&n!=-)
{
double stahm=n/whm;
double stahs=n/whs;
double stams=n/wms;
double endhm=(-n)/whm;
double endhs=(-n)/whs;
double endms=(-n)/wms;
double shm,shs,sms,ehm,ehs,ems;
const double T_hm=43200.0/,T_hs=43200.0/,T_ms=3600.0/; //Ïà¶ÔÖÜÆÚ
double sum=;
//cout<<"do"<<endl;
for(shm=stahm,ehm=endhm; ehm<43200.000001; shm+=T_hm,ehm+=T_hm)
{
//cout<<shm<<endl;
for(shs=stahs,ehs=endhs; ehs<43200.000001; shs+=T_hs,ehs+=T_hs)
{
if(ehm<shs) break;
if(shm>ehs) continue;
for(sms=stams,ems=endms; ems<43200.000001; sms+=T_ms,ems+=T_ms)
{
if(ehm<sms||ehs<sms) break;
if(shm>ems||shs>ems) continue;
//cout<<"doing"<<endl;
double xsta=max(shm,shs,sms);
double xend=min(ehm,ehs,ems);
if(xsta<xend)
sum+=(xend-xsta); }
}
}
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 5908 Abelian Period (BestCoder Round #88 模拟+暴力)

    HDU 5908 Abelian Period (BestCoder Round #88 模拟+暴力) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=59 ...

  7. HDU 1006 [Tick Tick]时钟问题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1006 题目大意:钟表有时.分.秒3根指针.当任意两根指针间夹角大于等于n°时,就说他们是happy的, ...

  8. HDU 1006 Tick and Tick 解不等式解法

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

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

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

随机推荐

  1. 使用PowerDesigner建立数据库模型【转】

    1. 打开PowerDesigner,点击File->New 2. 选择Conceptual Data Model,并修改Model name. 3.  在Palette工具栏中点击Entity ...

  2. Hadoop HDFS分布式文件系统设计要点与架构(转摘)

    Hadoop简介:一个分布式系统基础架构,由Apache基金会开发.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群的威力高速运算和存储.Hadoop实现了一个分布式文件系统(Ha ...

  3. Backup and restore of FAST Search for SharePoint 2010

    一个同事问我一个问题: 如果FAST Search for SharePoint 2010被full restore到了一个之前的时间点, 那么当FAST Search重新开始一个增量爬网的时候, 会 ...

  4. /etc/ssh/sshd_config 配置(ssh连接)

    # Package generated configuration file# See the sshd_config(5) manpage for details # What ports, IPs ...

  5. 扩展JQUERY 表单加载JSON数据

    $.fn.extend({ //表单加载json对象数据 setForm : function (jsonValue) { var obj = this; $.each(jsonValue, func ...

  6. (笔试题)质数因子Prime Factor

    题目: Given any positive integer N, you are supposed to find all of its prime factors, and write them ...

  7. 查看慢sql语句

    查看慢sql语句 st.text AS SQL_Full --父级完整语句 ,) , ((CASE statement_end_offset THEN DATALENGTH(st.text) ELSE ...

  8. STDIN_FILENO vs stdin

    数据类型不一致:stdin类型为 FILE*STDIN_FILENO类型为 int 使用stdin的函数主要有:fread.fwrite.fclose等,基本上都以f开头使用STDIN_FILENO的 ...

  9. (一)maven之——maven基础及本地仓库的配置

    一.初步了解maven Apache Maven是一个软件项目管理的综合工具.基于项目对象模型(POM)的概念,提供了帮助管理构建.文档.报告.依赖.发布等方法,Maven简化和标准化项目建设过程.处 ...

  10. PHP-"php://(类型)"访问各个输入/输出流以及全局变量$HTTP_RAW_POST_DATA讲解

    $_POST $HTTP_RAW_POST_DATA php://input 先来讲以上三者的区别: $_POST:以关联数组方式组织提交的数据, 并对原数据进行编码处理(urldecode)和编码转 ...