标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16707 Accepted Submission(s): 4083
计算出每两个指针满足要求的角度所需的时间,及周期,然后按周期循环。
#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/12/3600; double wm=360.0/60/60; double ws=360.0/60; 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!=-1) { double stahm=n/whm; double stahs=n/whs; double stams=n/wms; double endhm=(360-n)/whm; double endhs=(360-n)/whs; double endms=(360-n)/wms; double shm,shs,sms,ehm,ehs,ems; const double T_hm=43200.0/11,T_hs=43200.0/719,T_ms=3600.0/59; //Ïà¶ÔÖÜÆÚ double sum=0; //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/432); } return 0; }
标签:
原文地址:http://www.cnblogs.com/superxuezhazha/p/5471175.html