結果

問題 No.1624 三角形の反射
ユーザー bal4ubal4u
提出日時 2021-08-11 18:23:35
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 930 ms
コンパイル使用メモリ 31,660 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 09:48:45
合計ジャッジ時間 2,786 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 5 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 12 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 19 ms
4,348 KB
testcase_11 AC 12 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 1624 三角形の反射
// 2021.8.11

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

const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b)) <= eps)
#define EQZ(a) ((fabs(a)) <= eps)
int aw, ap;

void calc(double px, double py, double fx, double fy) {
	double a, x, y;
	if (EQZ(px) && EQZ(py)) { ap = 'A'; return; }
	if (EQ(px, 1) && EQZ(py)) { ap = 'B'; return; }
	if (EQZ(px) && EQ(py, 1)) { ap = 'C'; return; }
	++aw;

	a = (fy-py)/(fx-px);
	x = px - py/a, y = py - px*a;
	if      (!EQZ(px) && y >= 0 && y <= 1.0) calc(0, y, -fx, fy); // x == 0
	else if (!EQZ(py) && x >= 0 && x <= 1.0) calc(x, 0, fx, -fy); // y == 0
	else { // y == -x+1
		x = (1+a*px-py)/(1+a), y = (py+a*(1-px))/(1+a);
		calc(x, y, 1-fy, 1-fx);
	}
}

int main() {
	double a;
	scanf("%lf", &a);
	calc(1.0/(1+a), a/(1+a), 1.0, 1.0);
	if (aw < 0) puts("-1");
	else printf("%c %d\n", ap, aw);
	return 0;
}
0