結果

問題 No.2555 Intriguing Triangle
ユーザー EvbCFfp1XBEvbCFfp1XB
提出日時 2023-12-01 20:49:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,303 bytes
コンパイル時間 5,380 ms
コンパイル使用メモリ 78,852 KB
実行使用メモリ 59,976 KB
最終ジャッジ日時 2023-12-01 20:49:53
合計ジャッジ時間 10,826 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,840 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 130 ms
57,688 KB
testcase_06 AC 130 ms
57,844 KB
testcase_07 AC 129 ms
55,880 KB
testcase_08 AC 131 ms
57,816 KB
testcase_09 AC 134 ms
57,828 KB
testcase_10 AC 139 ms
57,964 KB
testcase_11 AC 140 ms
55,744 KB
testcase_12 AC 141 ms
58,088 KB
testcase_13 AC 140 ms
57,960 KB
testcase_14 AC 142 ms
58,068 KB
testcase_15 AC 138 ms
57,952 KB
testcase_16 AC 134 ms
57,952 KB
testcase_17 AC 129 ms
57,840 KB
testcase_18 WA -
testcase_19 AC 129 ms
56,672 KB
testcase_20 AC 144 ms
59,976 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 130 ms
57,832 KB
testcase_24 AC 132 ms
58,084 KB
testcase_25 AC 133 ms
57,952 KB
testcase_26 AC 142 ms
57,952 KB
testcase_27 AC 140 ms
57,832 KB
testcase_28 AC 131 ms
57,816 KB
testcase_29 AC 133 ms
57,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Optional;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int de = in.nextInt();
            int ab = in.nextInt();
            // d
            // e
            int ac = in.nextInt();

            boolean res = false;
            for (int bd = 1; bd <= 100; bd++) {
                for (int ec = 1; ec <= 100; ec++) {
                    if (bd + de + ec >= ab + ac) {
                        break;
                    }

                    Optional<Double> cos_dba = cosine_formula(ac, ab, bd + de + ec);
                    Optional<Double> cos_eca = cosine_formula(ab, ac, bd + de + ec);
                    if (cos_dba.isEmpty() || cos_eca.isEmpty()) {
                        continue;
                    }
                    double dba = Math.acos(cos_dba.get().doubleValue());
                    double eca = Math.acos(cos_eca.get().doubleValue());

                    double ad = Math.sqrt(cosine_formula2(ab, bd, dba));
                    double ae = Math.sqrt(cosine_formula2(ac, ec, eca));

                    Optional<Double> cos_bad = cosine_formula(bd, ab, ad);
                    Optional<Double> cos_cae = cosine_formula(ec, ac, ae);
                    if (cos_bad.isEmpty() || cos_cae.isEmpty()) {
                        continue;
                    }
                    double bad = Math.acos(cos_bad.get().doubleValue());
                    double cae = Math.acos(cos_cae.get().doubleValue());

//                    Utils.debug(de, ab, ac, bd, ec, dba, eca, ad, ae, bad, cae, Math.abs(bad - cae) < 1e-3);
                    if (Math.abs(bad - cae) < 1e-3) {
                        res = true;
                    }
                }
            }
            System.out.println(res ? "Yes" : "No");
        }
    }

    private static final Optional<Double> cosine_formula(double a, double b, double c) {
        double cos = (b * b + c * c - a * a) / (2.0d * b * c);
        if (Math.abs(cos) > 1.0d) {
            return Optional.empty();
        }
        return Optional.of(cos);
    }

    private static final double cosine_formula2(double b, double c, double cab) {
        return b * b + c * c - 2.0 * b * c * Math.cos(cab);
    }
}
0