思路:模拟。以钟表中心建立直角坐标系,根据每根针权重计算出重心,确定长度,并根据当前时间确定每根针的角度,计算出相应的x,y坐标,这样每一秒的距离都计算出来了
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const double PI = acos(-1.0);
int l1, l2, l3, m1, m2, m3;
int hh, mm, ss;
int st, ed;
struct Point {
double x, y;
};
double getdis(Point a, Point b) {
return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}
Point getpoint(int t) {
Point p, ph, pm, ps;
double w = m1 + m2 +m3;
double lh, lm, ls, ah, am, as;
lh = l1*m1/w;
lm = l2*m2/w;
ls = l3*m3/w;
ah = 2*PI*t/43200;
am = 2*PI*t/3600;
as = 2*PI*t/60;
ph.x = sin(ah)*lh;
ph.y = cos(ah)*lh;
pm.x = sin(am)*lm;
pm.y = cos(am)*lm;
ps.x = sin(as)*ls;
ps.y = cos(as)*ls;
p.x = ph.x + pm.x + ps.x;
p.y = ph.y + pm.y + ps.y;
return p;
}
int main() {
while (1) {
scanf("%d", &l1);
if (l1 == -1)
break;
scanf("%d %d %d %d %d", &l2, &l3, &m1, &m2, &m3);
scanf("%d:%d:%d", &hh, &mm, &ss);
st = hh*3600 + mm*60 + ss;
scanf("%d:%d:%d", &hh, &mm, &ss);
ed = hh*3600 + mm*60 + ss;
Point p1, p2;
p1 = getpoint(st);
double ans = 0;
int i;
for (i = st+1; i <= ed; ++i) {
p2 = getpoint(i);
ans += getdis(p1, p2);
p1 = p2;
}
printf("%.2lf\n", ans/2);
}
return 0;
}