結果
| 問題 |
No.760 Where am I moved to?
|
| コンテスト | |
| ユーザー |
iicafiaxus
|
| 提出日時 | 2018-12-08 01:32:50 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,025 bytes |
| コンパイル時間 | 3,190 ms |
| コンパイル使用メモリ | 174,080 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-13 02:06:13 |
| 合計ジャッジ時間 | 10,176 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
real xa = read.to!real;
real ya = read.to!real;
real tha = read.to!real;
real x11 = read.to!real;
real y11 = read.to!real;
real x12 = read.to!real;
real y12 = read.to!real; // ぴったり重なるのを防止
real x21 = read.to!real;
real y21 = read.to!real;
real x22 = read.to!real;
real y22 = read.to!real;
// AがA'にうつるように平行移動すると、Bは…
debug writeln("p = (", x21 - x11, ", ", y21 - y11, ")");
real b1x = x12 + (x21 - x11);
real b1y = y12 + (y21 - y11);
debug writeln("B1(", b1x, ", ", b1y, ")");
// これがB'にうつるように回転する回転角
real ux = b1x - x21;
real uy = b1y - y21;
debug writeln("u = (", ux, ", ", uy, ")");
real vx = x22 - x21;
real vy = y22 - y21;
debug writeln("v = (", vx, ", ", vy, ")");
real c = (ux * vx + uy * vy) / sqrt(ux * ux + uy * uy) / sqrt(vx * vx + vy * vy);
if(c > 1) c = 1;
if(c < -1) c = -1;
real s = (ux * vy - vx * uy) / sqrt(ux * ux + uy * uy) / sqrt(vx * vx + vy * vy);
real th = (s >= 0? acos(c): 2.0 * PI - acos(c)) / 2.0 / PI * 360.0;
debug writeln("th = ", th, " = (", c, ", ", s, ")");
// これらの逆変換を船に施す
real oux = xa - x21;
real ouy = ya - y21;
debug writeln("u = (", oux, ", ", ouy, ")");
real ovx = c * oux + s * ouy;
real ovy = -s * oux + c * ouy;
debug writeln("v = (", ovx, ", ", ovy, ")");
real o1x = x21 + ovx;
real o1y = y21 + ovy;
debug writeln("O1(", o1x, ", ", o1y, ")");
real o2x = o1x - (x21 - x11);
real o2y = o1y - (y21 - y11);
debug writeln("O2(", o2x, ", ", o2y, ")");
real th2 = tha - th;
th2 += 360.0 + 360.0;
while(th2 >= 360.0) th2 -= 360.0;
writeln(o2x.format!"%6.6f", " ", o2y.format!"%6.6f", " ", th2.format!"%6.6f");
}
iicafiaxus