結果

問題 No.760 Where am I moved to?
ユーザー iicafiaxusiicafiaxus
提出日時 2018-12-08 01:16:09
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 1,950 bytes
コンパイル時間 2,369 ms
コンパイル使用メモリ 168,984 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 21:27:05
合計ジャッジ時間 7,332 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 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