博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Tick and Tick
阅读量:6175 次
发布时间:2019-06-21

本文共 1955 字,大约阅读时间需要 6 分钟。

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"using namespace std;inline double max(double a,double b,double c){    a=a>b?a:b;    a=a>c?a:c;    return a;}inline double min(double a,double b,double c){    a=a
>an&&an!=-1) { tsm[0]=(10*an)/59; tsh[0]=(120*an)/719; tmh[0]=(120*an)/11; tsm[1]=s-tsm[0]; tsh[1]=m-tsh[0]; tmh[1]=h-tmh[0]; double sum=0; double x=0,y=0; int i,j; for(i=2,j=3;;i+=2,j+=2) { tsm[i]=tsm[i-2]+s; tsm[j]=tsm[j-2]+s; if(tsm[i]>43200&&tsm[j]>43200) break; } for(i=2,j=3;;i+=2,j+=2) { tsh[i]=tsh[i-2]+m; tsh[j]=tsh[j-2]+m; if(tsh[i]>43200&&tsh[j]>43200) break; } for(i=2,j=3;;i+=2,j+=2) { tmh[i]=tmh[i-2]+h; tmh[j]=tmh[j-2]+h; if(tmh[i-2]>43200&&tmh[j]>43200) break; } int a[2],b[2],c[2]; a[0]=b[0]=c[0]=0; a[1]=b[1]=c[1]=1; while(x<=43200&&y<=43200) { x=max(tsm[a[0]],tsh[b[0]],tmh[c[0]]); y=min(tsm[a[1]],tsh[b[1]],tmh[c[1]]); if(x
View Code

 

转载于:https://www.cnblogs.com/767355675hutaishi/p/3721176.html

你可能感兴趣的文章
接口测试Fiddler实战
查看>>
那个能报警的相机有了新伙伴:海康威视运动相机登场
查看>>
CSVDE批量导入域用户并更改密码和启用
查看>>
NULL与""空字符串的区别
查看>>
OSPF邻居关系建立过程详解
查看>>
JDK10 EA版特性速览
查看>>
超过254个IP,如何规划子网
查看>>
Amoeba新版本MYSQL读写分离配置
查看>>
制作XPE启动光盘的教程
查看>>
计算机网络基础
查看>>
一步步打造漂亮的新闻列表(无刷新分页、内容预览)(2)
查看>>
cron任务计划
查看>>
苹果iOS开发深入浅出Cocoa之类与对象
查看>>
介绍maven构建的生命周期
查看>>
PowerDesigner逆向工程导入MYSQL数据库总结
查看>>
摆脱DOM操作,从TodoMVC看angularJS
查看>>
POJ 3673 Cow Multiplication
查看>>
打算开源的东西
查看>>
Generation and Handling of Metadata Locks on RDS for MySQL Tables
查看>>
学会和同事相处的30个原则
查看>>