結果
| 問題 |
No.1624 三角形の反射
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2021-08-11 18:23:35 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 873 bytes |
| コンパイル時間 | 456 ms |
| コンパイル使用メモリ | 32,128 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 04:52:47 |
| 合計ジャッジ時間 | 1,639 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 1 |
ソースコード
// 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;
}
bal4u