标签:style blog class code tar c
#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<b?a:b; a=a<c?a:c; return a; } int main() { double an; double tsm[1445],tsh[1445],tmh[26]; double s,m,h; s=3600.00/59;//周期结束点 m=43200.00/719; h=43200.00/11; while(cin>>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<y) sum+=(y-x); if(y==tsm[a[1]]) { a[0]+=2; a[1]+=2; } if(y==tsh[b[1]]) { b[0]+=2; b[1]+=2; } if(y==tmh[c[1]]) { c[0]+=2; c[1]+=2; } } cout.precision(3); cout<<fixed<<sum/432<<endl; } return 0; }
标签:style blog class code tar c
原文地址:http://www.cnblogs.com/767355675hutaishi/p/3721176.html