这个题看了题解后再做的…数学题
这个题需要算一下这三个针两两重新达到同样的角度时的周期,举个例子,比如说,要求的角度是0°吧,也就是“套圈”的时间。以秒针和分针举例,先算秒针和分针的相对角速度
#include
#include
#include
using namespace std;
const double maxn=43200.00000;
double Max(double a,double b,double c)
{
return max(max(a,b),c);
}
double Min(double a,double b,double c)
{
return min(min(a,b),c);
}
const double Vsm=59./10,Vsh=719./120,Vmh=11./120;
const double Tsm=3600./59,Tsh=43200./719,Tmh=43200./11;
int main()
{
double D;
while(scanf("%lf",&D),D!=-1)
{
double tot,begin,end;
double Bsm=D/Vsm;
double Bsh=D/Vsh;
double Bmh=D/Vmh;
double Esm=Tsm-Bsm;
double Esh=Tsh-Bsh;
double Emh=Tmh-Bmh;
double i,j,k;
for(i=Bsm;i<=maxn;i+=Tsm)
{
for(j=Bsh;j<=maxn;j+=Tsh)
{
if(i+(Esm-Bsm)break;
if(i>j+(Esh-Bsh)) continue;
for(k=Bmh;k<=maxn;k+=Tmh)
{
if(k+(Emh-Bmh)continue;
if(k>(Esh-Bsh)+j||k>(Esm-Bsm)+i) break;
begin=Max(i,j,k); end=Min(i+(Esm-Bsm),j+(Esh-Bsh),k+(Emh-Bmh));
if(end>begin)
tot+=(end-begin);
}
}
}
printf("%.3lf\n",tot/432);
}
return 0;
}