結果

問題 No.306 さいたま2008
ユーザー kichirb3kichirb3
提出日時 2018-03-24 22:18:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 909 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2023-09-07 08:58:22
合計ジャッジ時間 1,481 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,948 KB
testcase_01 AC 14 ms
7,900 KB
testcase_02 AC 13 ms
7,792 KB
testcase_03 AC 14 ms
7,744 KB
testcase_04 AC 13 ms
7,800 KB
testcase_05 AC 14 ms
7,740 KB
testcase_06 AC 13 ms
7,940 KB
testcase_07 AC 12 ms
7,900 KB
testcase_08 AC 13 ms
7,820 KB
testcase_09 AC 13 ms
7,828 KB
testcase_10 AC 13 ms
7,792 KB
testcase_11 AC 13 ms
7,820 KB
testcase_12 AC 13 ms
7,940 KB
testcase_13 AC 13 ms
7,936 KB
testcase_14 AC 13 ms
7,888 KB
testcase_15 AC 13 ms
7,940 KB
testcase_16 AC 13 ms
7,932 KB
testcase_17 AC 13 ms
7,792 KB
testcase_18 AC 13 ms
7,900 KB
testcase_19 AC 12 ms
7,860 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 13 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.306 さいたま2008
https://yukicoder.me/problems/no/306

"""
import sys
from sys import stdin
input = stdin.readline


def calc_dist(ax, ay, bx, by, py):
    ap = (ax**2 + (ay - py)**2)**0.5
    bp = (bx**2 + (by - py)**2)**0.5
    return ap + bp


def solve(ax, ay, bx, by):
    uy = max(ay, by)
    ly = min(ay, by)

    if uy == ly:
        return ly

    for _ in range(100):
        py1 = (ly*2 + uy) / 3
        mid1_score = calc_dist(ax, ay, bx, by, py1)
        py2 = (ly + uy*2) / 3
        mid2_score = calc_dist(ax, ay, bx, by, py2)
        if mid2_score > mid1_score:
            uy = py2
        else:
            ly = py1
    return (uy + ly) / 2


def main(args):
    ax, ay = map(float, input().split())
    bx, by = map(float, input().split())
    ans = solve(ax, ay, bx, by)
    print('{:8f}'.format(ans))


if __name__ == '__main__':
    main(sys.argv[1:])
0