結果
問題 |
No.1027 U+1F4A0
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:35:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,990 bytes |
コンパイル時間 | 147 ms |
コンパイル使用メモリ | 82,212 KB |
実行使用メモリ | 54,564 KB |
最終ジャッジ日時 | 2025-03-20 20:36:50 |
合計ジャッジ時間 | 1,764 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
import math D1, D2 = map(int, input().split()) s = math.sqrt(D2) points = set() # Edge AB: x + y = s (from (s,0) to (0,s)) a = 2 b = -2 * s c = s**2 - D1 discriminant = b**2 - 4 * a * c if discriminant >= 0: sqrt_d = math.sqrt(discriminant) x1 = (-b + sqrt_d) / (2 * a) x2 = (-b - sqrt_d) / (2 * a) for x in [x1, x2]: if 0 <= x <= s: y = s - x x_round = round(x, 9) y_round = round(y, 9) points.add((x_round, y_round)) # Edge BC: x - y = -s (from (0,s) to (-s,0)) a = 2 b = 2 * s c = s**2 - D1 discriminant = b**2 - 4 * a * c if discriminant >= 0: sqrt_d = math.sqrt(discriminant) x1 = (-b + sqrt_d) / (2 * a) x2 = (-b - sqrt_d) / (2 * a) for x in [x1, x2]: if -s <= x <= 0: y = x + s x_round = round(x, 9) y_round = round(y, 9) points.add((x_round, y_round)) # Edge CD: x + y = -s (from (-s,0) to (0,-s)) a = 2 b = 2 * s c = s**2 - D1 discriminant = b**2 - 4 * a * c if discriminant >= 0: sqrt_d = math.sqrt(discriminant) x1 = (-b + sqrt_d) / (2 * a) x2 = (-b - sqrt_d) / (2 * a) for x in [x1, x2]: if -s <= x <= 0: y = -s - x x_round = round(x, 9) y_round = round(y, 9) points.add((x_round, y_round)) # Edge DA: x - y = s (from (0,-s) to (s,0)) a = 2 b = -2 * s c = s**2 - D1 discriminant = b**2 - 4 * a * c if discriminant >= 0: sqrt_d = math.sqrt(discriminant) x1 = (-b + sqrt_d) / (2 * a) x2 = (-b - sqrt_d) / (2 * a) for x in [x1, x2]: if 0 <= x <= s: y = x - s x_round = round(x, 9) y_round = round(y, 9) points.add((x_round, y_round)) # Check vertices if they lie on the circle if D1 == D2: vertices = [(s, 0), (0, s), (-s, 0), (0, -s)] for (x, y) in vertices: x_round = round(x, 9) y_round = round(y, 9) points.add((x_round, y_round)) print(len(points))