結果

問題 No.760 Where am I moved to?
ユーザー bal4ubal4u
提出日時 2019-11-18 14:30:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,878 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 33,280 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 22:06:38
合計ジャッジ時間 5,761 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 0 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 0 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.760 Where am I moved to?
// bal4u 2019.8.18

#include <stdio.h>
#include <ctype.h>
#include <math.h>

#if 0
int getchar_unlocked();
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

#if 1
double getdbl() { double a; scanf("%lf", &a); return a; }
#else
double getdbl() {   // 実数の入力
	int minus = 0;
	double x, y;
	int n = 0, c = gc();
	while (isspace(c)) c = gc();
	if (c == '-') minus = 1, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');

	if (c == '.') {
		x = 0;
		y = 1, c = gc();
		do y *= 0.1, x += y * (c & 0xf), c = gc(); while (c >= '0');
		x += n;
	} else x = n;
	if (minus) x = -x;
	return x;
}
#endif

#define PI 3.1415926535897932384626433832795
#define EPS 1e-13
typedef struct { double x, y; } PP;

PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
double dist(PP p1, PP p2) {	return hypot(p1.x-p2.x, p1.y-p2.y); }
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }
PP rot(PP a, double delta) {
	PP r;
	r.x = a.x*cos(delta) - a.y*sin(delta);
	r.y = a.x*sin(delta) + a.y*cos(delta);
	return r;
}

int main()
{
	double da, db, d;
	PP pa, pb, p11, p12, p21, p22, p1, p2;

	pa.x = getdbl(), pa.y = getdbl(), da = getdbl()/180*PI;
	p11.x = getdbl(), p11.y = getdbl();
	p12.x = getdbl(), p12.y = getdbl();
	p21.x = getdbl(), p21.y = getdbl();
	p22.x = getdbl(), p22.y = getdbl();
	
	p1 = vsub(p12, p11), p2 = vsub(p22, p21);
	d = atan2(p1.y, p1.x) - atan2(p2.y, p2.x);
	
	db = da + d;
	pb = vsub(p11, rot(vsub(p21, pa), d));
	printf("%.12lf %.12lf %.12lf\n", pb.x+EPS, pb.y+EPS, db/PI*180+EPS);
	return 0;
}
0