結果

問題 No.760 Where am I moved to?
ユーザー iicafiaxus
提出日時 2018-12-08 01:16:09
言語 D
(dmd 2.083.0)
結果
WA   .
実行時間 -
コード長 1,950 Byte
コンパイル時間 3,438 ms
使用メモリ 8,916 KB
最終ジャッジ日時 2018-12-08 01:16:17

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
1a WA -
1b AC 1 ms
6,872 KB
1c WA -
2a AC 0 ms
6,872 KB
2b AC 1 ms
6,868 KB
2c AC 2 ms
6,868 KB
2d AC 2 ms
6,872 KB
2e AC 1 ms
6,872 KB
99_system_test1.txt AC 2 ms
6,872 KB
99_system_test2.txt AC 2 ms
6,872 KB
99_system_test3.txt AC 2 ms
6,872 KB
テストケース一括ダウンロード

ソースコード

diff #
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;
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 + 0.00001;
	real y12 = read.to!real + 0.00001; // ぴったり重なるのを防止
	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);
	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, " ", o2y, " ", th2);
	
}
0