結果
問題 |
No.306 さいたま2008
|
ユーザー |
![]() |
提出日時 | 2018-03-24 22:24:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,099 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2025-02-14 12:14:36 |
合計ジャッジ時間 | 2,095 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
# -*- coding: utf-8 -*- """ No.306 さいたま2008 https://yukicoder.me/problems/no/306 """ import sys from sys import stdin from decimal import * input = stdin.readline def calc_dist(ax, ay, bx, by, py): ap = (ax*ax + (ay-py)*(ay-py)) bp = (bx*bx + (by-py)*(by-py)) return ap.sqrt() + bp.sqrt() def solve(ax, ay, bx, by): uy = Decimal(max(ay, by)) ly = Decimal(min(ay, by)) if uy == ly: return ly dax = Decimal(ax) day = Decimal(ay) dbx = Decimal(bx) dby = Decimal(by) getcontext().prec = 28 for _ in range(100): py1 = Decimal((ly*2 + uy) / 3) mid1_score = calc_dist(dax, day, dbx, dby, py1) py2 = Decimal((ly + uy*2) / 3) mid2_score = calc_dist(dax, day, dbx, dby, 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('{:f}'.format(ans)) if __name__ == '__main__': main(sys.argv[1:])