結果

問題 No.186 中華風 (Easy)
ユーザー しらっ亭しらっ亭
提出日時 2015-08-10 20:33:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-09-27 00:47:51
合計ジャッジ時間 4,382 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
7,804 KB
testcase_01 AC 67 ms
7,844 KB
testcase_02 AC 76 ms
7,780 KB
testcase_03 AC 16 ms
7,832 KB
testcase_04 AC 136 ms
7,912 KB
testcase_05 AC 129 ms
7,820 KB
testcase_06 AC 205 ms
7,772 KB
testcase_07 AC 155 ms
7,816 KB
testcase_08 AC 239 ms
7,788 KB
testcase_09 AC 238 ms
7,820 KB
testcase_10 AC 252 ms
7,844 KB
testcase_11 AC 309 ms
7,804 KB
testcase_12 AC 81 ms
7,756 KB
testcase_13 AC 107 ms
7,828 KB
testcase_14 AC 115 ms
7,776 KB
testcase_15 AC 27 ms
7,860 KB
testcase_16 AC 72 ms
7,776 KB
testcase_17 AC 20 ms
7,756 KB
testcase_18 AC 47 ms
7,944 KB
testcase_19 AC 149 ms
7,912 KB
testcase_20 AC 56 ms
7,796 KB
testcase_21 AC 132 ms
7,824 KB
testcase_22 AC 143 ms
7,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a, b):
    m, n = min(a, b), max(a, b)

    while n != 0:
        m, n = n, m % n
    return m


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


def solve():
    x1, y1 = list(map(int, input().split()))
    x2, y2 = list(map(int, input().split()))
    x3, y3 = list(map(int, input().split()))

    lcm12 = lcm(y1, y2)

    for a in range(y2):
        p = a * y1 + x1
        if p % y2 == x2:
            for b in range(1 if p == 0 else 0, y3):
                q = b * lcm12 + p
                if q % y3 == x3:
                    print(q)
                    return
    print(-1)


if __name__ == '__main__':
    solve()
0