結果
問題 |
No.356 円周上を回る3つの動点の一致
|
ユーザー |
![]() |
提出日時 | 2025-03-20 21:11:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 140 ms / 5,000 ms |
コード長 | 832 bytes |
コンパイル時間 | 144 ms |
コンパイル使用メモリ | 82,088 KB |
実行使用メモリ | 56,972 KB |
最終ジャッジ日時 | 2025-03-20 21:13:04 |
合計ジャッジ時間 | 3,781 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
ソースコード
import math from functools import reduce def compute_gcd(a, b): return math.gcd(a, b) def compute_lcm(a, b): return a * b // compute_gcd(a, b) def multi_gcd(numbers): return reduce(lambda x, y: compute_gcd(x, y), numbers) def multi_lcm(numbers): return reduce(lambda x, y: compute_lcm(x, y), numbers, 1) # Read input T1 = int(input()) T2 = int(input()) T3 = int(input()) pairs = [(T1, T2), (T1, T3), (T2, T3)] numerators = [] denominators = [] for Ti, Tj in pairs: numerator = Ti * Tj denominator = Tj - Ti g = compute_gcd(numerator, denominator) simplified_num = numerator // g simplified_den = denominator // g numerators.append(simplified_num) denominators.append(simplified_den) lcm_num = multi_lcm(numerators) gcd_den = multi_gcd(denominators) print(f"{lcm_num}/{gcd_den}")