No.620 Guru Guru Gururin
Problem Statement
You are currently adrift in a swirling sea.
You know that a rescue ship will appear at coordinates $(g_x, g_y)$ at exactly time $T$, so you are trying to somehow swim there.
At any time other than $t=T$, the rescue ship is not there even if you are at coordinates $(g_x, g_y)$, so you cannot board it.
Now, at time $t=0$, you are at coordinates $(1, 0)$.
When you are at position $(x_t, y_t)$ at time $t$, by swimming from there with force $(u_{x, t}, u_{y, t})$ for $1$ second, you can move to position $(x_{t+1}, y_{t+1})$.
The rotation speed $\omega$ of the vortex and the speed $v$ at which you are carried outward from the center of the vortex at coordinates $(0, 0)$ are known in advance.
With these speeds, the coordinates at time $t+1$ can be calculated as follows.
$x_{t+1} = x_t - y_t \omega + x_t v + u_{x, t}$
$y_{t+1} = y_t + x_t \omega + y_t v + u_{y, t}$
The following video shows how you drift in a sea with $\omega = 0.3, v = 0.01$ when applying no force at all (that is, $u_{x, t} = u_{y, t}=0$).
You have only $p$ stamina left, so you cannot keep exerting much force.
Specifically, unless $\displaystyle \sum_{0\le t < T}(u_{x, t}^2 + u_{y, t}^2) < p$ is satisfied, you will run out of strength before reaching the rescue ship.
For $n$ different settings of vortex strength, rescue ship appearance time, and rescue ship appearance position,
compute, for each one, one example of how to apply force so that you can reach the rescue ship without running out of strength.
Input
n T p omega v g_x g_y ... T p omega v g_x g_y
$1 \le n \le 1000$
$1 \le T \le 15$, integer
$0 \le p \le 10^9$, decimal
$-3 \le \omega, v \le 3$, decimal
$-100 \le g_x, g_y \le 100$, decimal
Decimal inputs are given up to the 4th decimal place (nothing from the 5th decimal place onward is given).
It is guaranteed that you can reach the rescue ship without running out of strength.
For each case, $p$ is at least $101$ % of the sum of squares of $u_{x, t}, u_{y, t}$ found by the Writer.
Output
For each case, output $T$ lines of $u_{x, t}, u_{y, t}$ for that case.
On line $t$ ($0\le t < T$), output the force $u_{x, t}, u_{y, t}$ applied during seconds $t\sim t+1$, separated by a space.
The Euclidean distance between $(x_T, y_T)$ and $(g_x, g_y)$ must be at most $10^{-4}$.
It must hold that $\displaystyle \sum_{0\le t < T} (u_{x, t}^2 + u_{y, t}^2) < p$.
Print a newline at the end.
Sample
Sample 1
Input
1 5 5.5 0.5 -0.5 -1.125 2.125
Output
1 0 1 0 1 0 0 1 0 1
Initially, $(x_0, y_0) = (1, 0)$.
$x_1 = x_0 - y_0 \cdot 0.5 + x_0 \cdot (-0.5) + 1 = 1.5$
$y_1 = y_0 + x_0 \cdot 0.5 + y_0 \cdot (-0.5) + 0 = 0.5$
$x_2 = x_1 - y_1 \cdot 0.5 + x_1 \cdot (-0.5) + 1 = 1.5$
$y_2 = y_1 + x_1 \cdot 0.5 + y_1 \cdot (-0.5) + 0 = 1$
$x_3 = x_2 - y_2 \cdot 0.5 + x_2 \cdot (-0.5) + 1 = 1.25$
$y_3 = y_2 + x_2 \cdot 0.5 + y_2 \cdot (-0.5) + 0 = 1.25$
$x_4 = x_3 - y_3 \cdot 0.5 + x_3 \cdot (-0.5) + 0 = 0$
$y_4 = y_3 + x_3 \cdot 0.5 + y_3 \cdot (-0.5) + 1 = 2.25$
$x_5 = x_4 - y_4 \cdot 0.5 + x_4 \cdot (-0.5) + 0 = -1.125$
$y_5 = y_4 + x_4 \cdot 0.5 + y_4 \cdot (-0.5) + 1 = 2.125$
The force is $\sum_{0\le t < T} (u_{x, t}^2 + u_{y, t}^2) = 5 < 5.5$, so you were able to move to $(-1.125, 2.125)$ at exactly time $T=5$ without running out of strength.
Note here that it must be exactly time $T$.
That is, even if you reach the rescue ship at a time $t < T$, you will not be rescued if you have moved to another place at exactly time $t=T$.
Sample 2
Input
1 15 10 0.9 0.1 1 0
Output
-0.5590832663553096838087753950308211869924 -0.4538251666614241209630250389883698858284 -0.1022519519779994767825093832103178215220 -0.4962290213105669546263341157521509217077 0.1654103821800548689447286215825627664344 -0.3157815248622887024281327694730236999021 0.2307696993931288061689026738787511305873 -0.0982625412804297967609258937504712605460 0.1694470081608061894849455789047176779150 0.0493088782402688876135453052707013910094 0.0703038210696261387682489546469000174511 0.1023475610935749273856364832679943788207 -0.0073161395087270862120910853640398663345 0.0870573050324732387750411265192607146446 -0.0427719445489236518612402408734407543989 0.0441477772167654059713281372578919103944 -0.0429614547024281751287882839818177416191 0.0049840618041635591964723991237340428029 -0.0256154731665434461238743755334690277436 -0.0164271491324782774210512591508970281495 -0.0066299931999826736638264240708551255921 -0.0203583118295128558297550375871809436035 0.0054601426369248197322989711588459016411 -0.0140401667784384298875424365582453845036 0.0092288648520925917442445617078217168228 -0.0052128985559520393583323588648781310440 0.0073481980384297593332336429039486347392 0.0012731633443131396118876835776845268811 0.0034342430857618008364050277148038503583 0.0039672563676555400234528814262802143276
The force is $\sum_{0\le t < T} (u_{x, t}^2 + u_{y, t}^2) = 1.0268684859$, so you can reach the rescue ship at exactly the required time with a force smaller than the remaining strength $10.0$.
Guru guru gururin.
Sample 3
Input
4 6 9770 0.1359 -0.1674 -3.4238 90.2458 8 4359 -2.9435 -2.7331 -33.5567 72.6887 1 8317 1.4861 -1.0168 72.7476 -5.3280 7 4249 1.0773 2.4532 4.1420 -4.4472
Output
8.8610640622215729803046180279579857597128 9.1624287318977981637441176943070786364842 8.6168617587290694441806704340081068949075 12.4110740390427459851549474301179998292355 7.7108320088957468634027758724869272555225 16.1649965278016668635691077682281502347905 5.9340532901000440243154121500168685088283 20.3836588637009756136420079997151333373040 3.0498513981872338589503013128734210113180 24.9797425758913909030201061511888838140294 -1.2019824014747570554983990831487972172908 29.8059009880592431125656549539826301042922 1.5774550919225495036963061168400201950135 2.6797588212359079336537942550577895417518 0.4417259778202559507916287462325755086567 -0.7959946947792882938096763190127802545248 -0.2664219693281557105779717986582255662142 0.0067980082291050485892578748598619187149 0.0412883921536529575847460082904660794156 0.0662018199037403666051913170287335219655 0.0105682176601090039463372305394983641236 -0.0202494208188849568767417319570256495354 -0.0066781880176901074579187689295167729142 0.0003416850665363352444053868239848270605 0.0010781542029716321279275703659550345037 0.0016339864000407908900536213536724972073 0.0002520679471596301568503406542731681839 -0.0005146947256041561891137803286255802959 72.7643999272356000740380466140777571126819 -6.8140999931859000064010567498939963115845 -3.1914891398354974239026660143281333148479 -0.9961849458246479833869839459747907994824 -0.7602242579764328366540362957870513582748 -0.5256499881103495447451541544570119413038 -0.1573479273710753174257259007218223700875 -0.2013091944478191229884848911790840020331 -0.0249506562886531407013317000742613771536 -0.0660803128887944921782387347475307137756 -0.0011441418288945185628463670213239566920 -0.0194929042282700865605649109824071274488 0.0013029071067033701106056831076074331577 -0.0052384114450990508244504484380854592018 0.0007751175941197825311479441268147638766 -0.0012751587134330459073761065980079365545
For the respective cases, $6, 8, 1, 7$ lines are output, so $22$ lines are output in total.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
はむこ