1006-Tick and Tick
来源:互联网 发布:windows代表什么 编辑:程序博客网 时间:2024/05/20 19:50
(http://acm.split.hdu.edu.cn/showproblem.php?pid=1006)
#include <iostream>#include <cmath>#include <iomanip> using namespace std;struct Segment{ double a,b;};double d;Segment makeseg1(double a, double b)//解集1 { Segment seg; seg.a=(a+d-360.0)/b; seg.b=(a-d)/b; if (seg.a<0.0) seg.a=0.0; if (seg.b>60.0) seg.b=60.0; if(seg.a>seg.b) seg.a=seg.b=0.0; return seg;}Segment makeseg2(double a, double b)//解集2 { Segment seg; seg.a=(a+d)/b; seg.b=(a-d+360.0)/b; if (seg.a<0.0) seg.a=0.0; if (seg.b>60.0) seg.b=60.0; if(seg.a>seg.b) seg.a=seg.b=0.0; return seg;}//求交集:定义运算符* Segment operator *(Segment S1,Segment S2) { Segment seg; seg.a = max(S1.a,S2.a); seg.b = min(S1.b,S2.b); if( seg.a >= seg.b ) seg.a = seg.b = 0.0; return seg;}int main(){ while(cin>>d) { if(d<0) break; double totlen=0.0; for(int h=0;h<12;h++) { for(int m=0;m<60;m++) { Segment s[3][2]; double a,b; a=30.0*h - 5.5*m; b=11.0/120; s[0][0]=makeseg1(a,b); s[0][1]=makeseg2(a,b); a=30.0*h + 0.5*m; b=719.0/120.0; s[1][0]=makeseg1(a,b); s[1][1]=makeseg2(a,b); a=6.0*m; b=5.9; s[2][0]=makeseg1(a,b); s[2][1]=makeseg2(a,b); for(int i=0;i<2;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++) { Segment tmp=s[0][i]*s[1][j]*s[2][k];//三者求交集 totlen+=tmp.b-tmp.a;//求并:每一段区间秒数累加 } } } cout<<setprecision(3)<<setiosflags(ios::fixed); cout<<totlen/432.0<<endl; } system("PAUSE"); return 1;}
0 0
- 1006 tick and tick
- 1006-Tick and Tick
- HDU 1006 Tick and Tick
- HDOJ 1006 Tick and Tick
- HDU 1006 Tick and Tick
- hdu 1006 Tick and Tick
- [HDU]1006 Tick and Tick
- HDU 1006 TICk and TICK
- HDU 1006 Tick and Tick
- Hdu 1006 Tick and Tick
- HDOJ 1006 Tick and Tick
- hdu 1006 Tick and Tick
- HDU 1006 Tick and Tick
- HDU:1006 Tick and Tick
- hdu 1006 Tick and Tick
- HDU 1006 Tick and Tick
- OJ problem(Tick and Tick) 1006
- hdu 1006 Tick and Tick 时钟问题
- 经常读错的单词,你读对了吗
- 记录几次内存泄露问题
- maven学习2-建立Java工程
- 在Ubunut12.04上搭建TFTP和NFS服务器
- -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable a
- 1006-Tick and Tick
- BNUOJ52325 Increasing or Decreasing(数位dp)
- vs2010 瘦身--ipch文件夹和sdf文件配置
- Ubuntu 12.04 安装 GitLab
- poj 1426 Find The Multiple(DFS)
- bnuoj 52317 As Easy As Possible(预处理+倍增法)
- SDUT OJ 数据结构实验之栈四:括号匹配
- python爬虫——模拟登陆教务系统
- java中String类常量池详解