int main(){ scanf("%d", &N); for(int i = 1;i <= N;++i) sphere[i].fromInput(); laser.fromInput(); for(int i = 1, hitOn = -1;i <= 11;++i, hitOn = -1){ double t = 1e9; for(int j = 1;j <= N;++j) if(sphere[j].intersection(laser, t)) hitOn = j; if(~hitOn){ ans[++ans[0]] = hitOn; const Sphere&curSphere = sphere[hitOn]; newLazer.O = laser.O + laser.dir * t; Coordinate Nomal = curSphere.O - newLazer.O; t = 2. * (Nomal * laser.dir) / sqr(Nomal.Length()); newLazer.dir = laser.dir - Nomal * t; laser = newLazer; }else break; } for(int i = 1;i <= min(ans[0], 10);++i) printf(i == 1 ? "%d" : " %d", ans[i]); if(ans[0] <= 10) puts(""); else puts(" etc."); return 0; }
double calcCosine(const Coordinate&a, const Coordinate&b){ return a * b / a.Length() / b.Length(); }