結果

問題 No.760 Where am I moved to?
ユーザー bal4ubal4u
提出日時 2019-08-18 12:39:44
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,728 bytes
コンパイル時間 620 ms
コンパイル使用メモリ 31,448 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 12:35:34
合計ジャッジ時間 4,035 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘getdbl’ 内:
main.c:8:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    8 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:16:24: 備考: in expansion of macro ‘gc’
   16 |         int n = 0, c = gc();
      |                        ^~

ソースコード

diff #

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

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

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

double getdbl() {   // 実数の入力
	int minus = 0;
	double x, y;
	int n = 0, 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;
}

#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