結果
問題 | No.229 線分上を往復する3つの動点の一致 |
ユーザー |
|
提出日時 | 2016-11-22 18:27:34 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,344 bytes |
コンパイル時間 | 110 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-11-27 09:41:09 |
合計ジャッジ時間 | 11,703 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | WA * 43 |
ソースコード
#!/usr/bin/env python3from fractions import Fractionfrom collections import defaultdictimport mathdef lcm(a, b):return a * b // math.gcd(a, b)def qlcm(p, q):a = p.numerator * q.denominatorb = p.denominator * q.numeratorc = p.denominator * q.denominatorreturn Fraction(lcm(a, b), c)def dir(v, t):x = v * t % 2return x < 1def pos(v, t):x = v * t % 2return min(x, 2 - x)t1 = int(input())t2 = int(input())t3 = int(input())v1 = Fraction(2, t1)v2 = Fraction(2, t2)v3 = Fraction(2, t3)t12 = lcm(t1, t2)t = Fraction(0)x = pos(v1, t)ans = float('inf')while t == 0 or x != 0:# update td1 = dir(v1, t)d2 = dir(v2, t)if d1 == d2 == True: # rightl = 2 * (1 - x)elif d1 == d2 == False: # leftl = 2 * xelse:l = 2t += l / (v1 + v2)x = pos(v1, t)# check P3y = pos(v3, t)for is_right in range(2):if is_right == x < y:dy = x + 1 + yelse:dy = abs(x - y)dt = dy / v3if dt == 0 or (t12 - t3) % dt == 0:if dt == 0:k = 0else:k = (t12 - t3) / dt# print(t + t12 * k, t + dt + t3 * k, k)if t + t12 * k == t + dt + t3 * k:ans = min(ans, t + t12 * k)print(ans)