結果

問題 No.1064 ∪∩∩ / Cup Cap Cap
ユーザー はむ吉🐹
提出日時 2020-05-29 21:48:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-11-06 03:37:17
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3


import decimal
import math


def analyze(a, b, c, d):
    det = (a - c) * (a - c) - decimal.Decimal(8) * (b - d)
    if det < 0:
        return (0, None)
    elif det == 0:
        return (1, None)
    else:
        sqrt_det = det ** decimal.Decimal(0.5)
        x_1 = (-(a - c) - sqrt_det) / decimal.Decimal(4)
        x_2 = (-(a - c) + sqrt_det) / decimal.Decimal(4)
        y_1 = x_1 * x_1 + a * x_1 + b
        y_2 = x_2 * x_2 + a * x_2 + b
        p = (y_1 - y_2) / (x_1 - x_2)
        q = y_1 - p * x_1
        return (2, (p, q))


def main():
    decimal.getcontext().prec = 28
    a, b, c, d = (decimal.Decimal(z) for z in input().split())
    num, pq = analyze(a, b, c, d)
    if num == 0:
        print("No")
    elif num == 1:
        print("Yes")
    else:
        p, q = pq
        print("{:.12f} {:.12f}".format(p, q))


if __name__ == '__main__':
    main()
0