結果

問題 No.356 円周上を回る3つの動点の一致
ユーザー HachimoriHachimori
提出日時 2016-04-02 11:04:01
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 1,105 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-04-21 22:41:41
合計ジャッジ時間 2,289 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,400 KB
testcase_01 AC 13 ms
6,272 KB
testcase_02 AC 11 ms
6,400 KB
testcase_03 AC 11 ms
6,272 KB
testcase_04 AC 11 ms
6,400 KB
testcase_05 AC 11 ms
6,400 KB
testcase_06 AC 12 ms
6,400 KB
testcase_07 AC 11 ms
6,400 KB
testcase_08 AC 11 ms
6,400 KB
testcase_09 AC 11 ms
6,272 KB
testcase_10 AC 11 ms
6,272 KB
testcase_11 AC 11 ms
6,400 KB
testcase_12 AC 11 ms
6,400 KB
testcase_13 AC 12 ms
6,272 KB
testcase_14 AC 12 ms
6,400 KB
testcase_15 AC 12 ms
6,400 KB
testcase_16 AC 11 ms
6,272 KB
testcase_17 AC 11 ms
6,400 KB
testcase_18 AC 11 ms
6,272 KB
testcase_19 AC 11 ms
6,400 KB
testcase_20 AC 12 ms
6,400 KB
testcase_21 AC 11 ms
6,272 KB
testcase_22 AC 11 ms
6,272 KB
testcase_23 AC 11 ms
6,272 KB
testcase_24 AC 11 ms
6,400 KB
testcase_25 AC 12 ms
6,272 KB
testcase_26 AC 11 ms
6,400 KB
testcase_27 AC 11 ms
6,400 KB
testcase_28 AC 11 ms
6,400 KB
testcase_29 AC 11 ms
6,400 KB
testcase_30 AC 11 ms
6,400 KB
testcase_31 AC 12 ms
6,400 KB
testcase_32 AC 11 ms
6,272 KB
testcase_33 AC 12 ms
6,400 KB
testcase_34 AC 12 ms
6,272 KB
testcase_35 AC 12 ms
6,400 KB
testcase_36 AC 12 ms
6,400 KB
testcase_37 AC 11 ms
6,400 KB
testcase_38 AC 11 ms
6,400 KB
testcase_39 AC 12 ms
6,400 KB
testcase_40 AC 11 ms
6,400 KB
testcase_41 AC 11 ms
6,400 KB
testcase_42 AC 11 ms
6,272 KB
testcase_43 AC 13 ms
6,400 KB
testcase_44 AC 12 ms
6,400 KB
testcase_45 AC 12 ms
6,400 KB
testcase_46 AC 12 ms
6,400 KB
testcase_47 AC 12 ms
6,272 KB
testcase_48 AC 12 ms
6,400 KB
testcase_49 AC 12 ms
6,400 KB
testcase_50 AC 11 ms
6,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8

def read():
    return (input(), input(), input())


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)
    

def lcd(a, b):
    return a * b / gcd(a, b)


def work((t1, t2, t3)):
    
    # P1 と P2 が一致する周期 (分子, 分母) (秒)
    p12 = [t1 * t2, abs(t1 - t2)]

    # P1 と P3 が一致する周期 (分子, 分母) (秒)
    p13 = [t1 * t3, abs(t1 - t3)]

    # P2 と P3 が一致する周期 (分子, 分母) (秒)
    p23 = [t2 * t3, abs(t2 - t3)]


    # p12 と p13 が最短で一致する時間
    # -> p12 * a = p13 * b   を満たす最小の数 (a = 1,2,3 ..., b = 1,2,3 ...)
    # -> p12 と p13 の最小公倍数

    # 分数の式を整数の式にする
    pp12 = p12[0] * p13[1]
    pp13 = p12[1] * p13[0]

    # pp12, pp13 の最小公倍数を取得
    ansInt = lcd(pp12, pp13)

    # 分数に戻す
    ans = [ansInt, p12[1] * p13[1]]
    
    # 約分する
    div = gcd(ans[0], ans[1])
    ans[0] /= div
    ans[1] /= div

    print "%d/%d" % (ans[0], ans[1])
    
    

if __name__ == "__main__":
    work(read())
0