Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15570 Accepted Submission(s): 3677
#include<iostream> #include<cstdio> using namespace std; const double s_h = 719./120,s_m = 59./10,m_h =11./120; const double tsh=43200./719,tsm =3600./59,tmh =43200./11; double MAX(double a,double b,double c) { double max=a; if (b>max) max=b; if(c>max) max=c; return max; } double MIN(double a,double b,double c) { double min=a; if (b<min) min=b; if (c<min) min=c; return min; } int main() { double N; while (~scanf("%lf",&N)) { if (N==-1) break; double bsm,bsh,bmh,esm,esh,emh,begin,end,sum=0; bsm=N/s_m; bsh=N/s_h; bmh=N/m_h; esm=(360-N)/s_m; esh=(360-N)/s_h; emh=(360-N)/m_h; for(double bt3=bsh,et3=esh;et3<=43200.000001;bt3+=tsh,et3+=tsh) { for (double bt2=bmh,et2=emh;et2<=43200.000001;bt2+=tmh,et2+=tmh) { if (et2<bt3) continue; if (bt2>et3) break; for (double bt1=bsm,et1=esm;et1<43200.000001;bt1+=tsm,et1+=tsm) { if (et1<bt2||et1<bt3) continue; if (bt1>et2||bt1>et3) break; begin=MAX(bt1,bt2,bt3); end=MIN(et1,et2,et3); sum+=(end-begin); } } } printf("%.3lf\n",sum/432); } return 0; }
原文:http://www.cnblogs.com/xfjy/p/4991307.html