{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003eYour game development studio, Ad Hoc Entertainment, is\n currently working on a billiards-based app they’re calling Pool\n Shark. Players face a sequence of increasingly devious pool\n puzzles in which they need to carefully position and aim a\n single billiards shot to sink multiple pool balls.\u003c/p\u003e\n\n \u003cp\u003eYou’ve just done the first round of user testing and the\n feedback is terrible — players complain that the physics of\n your pool game is neither fun nor intuitive. After digging into\n it, you realize that the problem isn’t that your physics code\n is bad, but rather that most people just don’t have much\n intuition about how physics works. Fortunately, no one requires\n your physics to be realistic. After this liberating\n realization, your team experiments with a few models,\n eventually settling on the following rule for how to resolve\n pool-ball collisions:\u003c/p\u003e\n\n \u003cp\u003eWhen a moving pool ball B hits a stationary ball A, A begins\n moving in the direction given by the vector from the center of\n B to the center of A at the time of the collision. Ball B’s new\n velocity vector is B’s original vector reflected across A’s new\n vector (Figure H.1). Note that A’s resulting vector is what\n real physics predicts, but B’s is not (unless A is glued to the\n table or has infinite mass). For the purposes of this problem,\n the speed at which the balls move is irrelevant.\u003c/p\u003e\n\n \u003ccenter\u003e\n \u003ctable cellspacing\u003d\"0\" class\u003d\"tabular\"\u003e\n \u003ctbody\u003e\u003ctr\u003e\n \u003ctd style\u003d\"text-align:center\"\u003e\n \u003cp\u003e\u003cimg src\u003d\"CDN_BASE_URL/763384855d3654bfd782e187c6f31e32?v\u003d1715309475\" alt\u003d\"\\includegraphics[width\u003d0.45\\linewidth ]{trickshot1}\" style\u003d\"width:0.45\"\u003e\u003c/p\u003e\n \u003c/td\u003e\n\n \u003ctd style\u003d\"text-align:center\"\u003e\u0026nbsp;\u003c/td\u003e\n\n \u003ctd style\u003d\"text-align:center\"\u003e\n \u003cp\u003e\u003cimg src\u003d\"CDN_BASE_URL/0ffd87a451f849549e92caf23a05f3f6?v\u003d1715309475\" alt\u003d\"\\includegraphics[width\u003d0.45\\linewidth ]{trickshot2}\" style\u003d\"width:0.45\"\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n \u003ctd style\u003d\"text-align:center\"\u003e\n \u003cp\u003eFigure H.1\u003c/p\u003e\n \u003c/td\u003e\n\n \u003ctd style\u003d\"text-align:center\"\u003e\u0026nbsp;\u003c/td\u003e\n\n \u003ctd style\u003d\"text-align:center\"\u003e\n \u003cp\u003eFigure H.2\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003c/tbody\u003e\u003c/table\u003e\n \u003c/center\u003e\n\n \u003cp\u003eThis actually allows for more interesting challenges, but\n requires new code to determine whether a particular level is\n feasible. You’ve been tasked with solving a very particular\n case:\u003c/p\u003e\n\n \u003cp\u003eThree balls labelled \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e, \u003cspan class\u003d\"tex2jax_process\"\u003e$2$\u003c/span\u003e, and \u003cspan class\u003d\"tex2jax_process\"\u003e$3$\u003c/span\u003e are placed on a table with width\n \u003cspan class\u003d\"tex2jax_process\"\u003e$w$\u003c/span\u003e and length\n \u003cspan class\u003d\"tex2jax_process\"\u003e$l$\u003c/span\u003e (Figure\u0026nbsp;H.2). The\n player must place the cue ball somewhere on a dashed line lying\n \u003cspan class\u003d\"tex2jax_process\"\u003e$h$\u003c/span\u003e units above the bottom\n edge of the table. The goal is to pick a distance \u003cspan class\u003d\"tex2jax_process\"\u003e$d$\u003c/span\u003e from the left side, and an angle\n \u003cspan class\u003d\"tex2jax_process\"\u003e$\\theta $\u003c/span\u003e such that when\n the cue ball is shot, the following events happen:\u003c/p\u003e\n\n \u003cul class\u003d\"itemize\"\u003e\n \u003cli\u003e\n \u003cp\u003eThe cue ball strikes ball \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e, and then ricochets into ball\n \u003cspan class\u003d\"tex2jax_process\"\u003e$2$\u003c/span\u003e, sinking ball\n \u003cspan class\u003d\"tex2jax_process\"\u003e$2$\u003c/span\u003e in the top left\n hole.\u003c/p\u003e\n \u003c/li\u003e\n\n \u003cli\u003e\n \u003cp\u003eBall \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e, having\n been struck by the cue ball, hits ball \u003cspan class\u003d\"tex2jax_process\"\u003e$3$\u003c/span\u003e, sinking ball \u003cspan class\u003d\"tex2jax_process\"\u003e$3$\u003c/span\u003e in the top right hole.\u003c/p\u003e\n \u003c/li\u003e\n \u003c/ul\u003e\n\n \u003cp\u003eFor simplicity, assume that sinking a ball requires the\n center of the ball to pass directly over the center of the\n hole. Further assume that the table has no sides — a ball that\n goes out of the \u003cspan class\u003d\"tex2jax_process\"\u003e$w$\u003c/span\u003e-by-\u003cspan class\u003d\"tex2jax_process\"\u003e$l$\u003c/span\u003e region simply falls into a digital\n abyss — and thus you don’t need to worry about balls colliding\n with the table itself.\u003c/p\u003e\n\n \u003cp\u003eYou need to write a program that, given values for\n \u003cspan class\u003d\"tex2jax_process\"\u003e$w$\u003c/span\u003e, \u003cspan class\u003d\"tex2jax_process\"\u003e$l$\u003c/span\u003e, \u003cspan class\u003d\"tex2jax_process\"\u003e$h$\u003c/span\u003e, the position of balls\n \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e–\u003cspan class\u003d\"tex2jax_process\"\u003e$3$\u003c/span\u003e, and the radius \u003cspan class\u003d\"tex2jax_process\"\u003e$r$\u003c/span\u003e of the balls, determines whether\n the trick shot is possible.\u003c/p\u003e\n\n \u003ch2\u003eInput\u003c/h2\u003e\n\n \u003cp\u003eThe input begins with a line containing two positive\n integers \u003cspan class\u003d\"tex2jax_process\"\u003e$w$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$l$\u003c/span\u003e, the width and length of the pool\n table, where \u003cspan class\u003d\"tex2jax_process\"\u003e$w, l \\leq\n 120$\u003c/span\u003e. The left hole is at location \u003cspan class\u003d\"tex2jax_process\"\u003e$(0,l)$\u003c/span\u003e and the right hole is at\n location \u003cspan class\u003d\"tex2jax_process\"\u003e$(w,l)$\u003c/span\u003e.\u003c/p\u003e\n\n \u003cp\u003eThe next line will contain 8 positive integers \u003cspan class\u003d\"tex2jax_process\"\u003e$r$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$x_1$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$y_1$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$x_2$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$y_2$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$x_3$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$y_3$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$h$\u003c/span\u003e, where \u003cspan class\u003d\"tex2jax_process\"\u003e$r \\leq 5$\u003c/span\u003e is the radius of all the\n balls (including the cue ball), \u003cspan class\u003d\"tex2jax_process\"\u003e$x_ i$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$y_ i$\u003c/span\u003e is the location of ball\n \u003cspan class\u003d\"tex2jax_process\"\u003e$i,\\, 1 \\leq i \\leq 3$\u003c/span\u003e,\n and \u003cspan class\u003d\"tex2jax_process\"\u003e$h$\u003c/span\u003e is the distance\n the dashed line is from the front of the pool table (see the\n figure above, where \u003cspan class\u003d\"tex2jax_process\"\u003e$r \\leq h\n \\leq (1/2)l$\u003c/span\u003e). No two balls will ever overlap, though\n they may touch at a point, and all balls will lie between the\n dashed line and the back of the table. All balls will lie\n completely on the table, and the cue ball must also lie\n completely on the table (otherwise the shot is impossible).\u003c/p\u003e\n\n \u003ch2\u003eOutput\u003c/h2\u003e\n\n \u003cp\u003eFor each test case, display the distance \u003cspan class\u003d\"tex2jax_process\"\u003e$d$\u003c/span\u003e to place the ball on the dashed\n line and the angle \u003cspan class\u003d\"tex2jax_process\"\u003e$\\theta\n $\u003c/span\u003e to shoot the ball, or the word “\u003ctt class\u003d\"ttfamily\"\u003eimpossible\u003c/tt\u003e” if the trick shot cannot be done.\n Output \u003cspan class\u003d\"tex2jax_process\"\u003e$\\theta $\u003c/span\u003e in\n degrees, and round both \u003cspan class\u003d\"tex2jax_process\"\u003e$d$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$\\theta $\u003c/span\u003e to the nearest hundredth.\n Always show two digits after the decimal point, even if the\n digits are zero.\u003c/p\u003e\n\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e20 30\n2 10 20 2 24 18 28 10\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e12.74 127.83\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n\n \u003ch2\u003eSample 2\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e20 30\n2 15 20 2 24 18 28 10\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eimpossible\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}