結果
問題 | No.356 円周上を回る3つの動点の一致 |
ユーザー |
![]() |
提出日時 | 2016-04-02 00:30:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,420 ms / 5,000 ms |
コード長 | 560 bytes |
コンパイル時間 | 294 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 88,960 KB |
最終ジャッジ日時 | 2024-10-13 21:06:42 |
合計ジャッジ時間 | 36,311 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
ソースコード
import fractions def gcd(a, b): while b: a, b = b, a%b return a def lcm(a, b): return a*b // gcd(a, b) def reduce(p, q): common = gcd(p, q) return (p // common, q // common) t1 = int(input()) t2 = int(input()) t3 = int(input()) t = lcm(t1, t2) t = lcm(t, t3) period = [t//t1, t//t2, t//t3] period_max = max(period) - 1 while period_max > 0: if period[0]%period_max == period[1]%period_max == period[2]%period_max: D = period_max break period_max -= 1 N, D = reduce(t, D) print(str(N) + "/" + str(D))