結果

問題 No.186 中華風 (Easy)
ユーザー しらっ亭しらっ亭
提出日時 2015-08-10 23:26:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 10,180 KB
最終ジャッジ日時 2023-10-17 15:51:39
合計ジャッジ時間 5,011 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
10,180 KB
testcase_01 AC 78 ms
10,180 KB
testcase_02 AC 85 ms
10,180 KB
testcase_03 AC 27 ms
10,180 KB
testcase_04 AC 156 ms
10,180 KB
testcase_05 AC 146 ms
10,180 KB
testcase_06 AC 221 ms
10,180 KB
testcase_07 AC 173 ms
10,180 KB
testcase_08 AC 259 ms
10,180 KB
testcase_09 AC 248 ms
10,180 KB
testcase_10 AC 208 ms
10,180 KB
testcase_11 AC 329 ms
10,180 KB
testcase_12 AC 93 ms
10,180 KB
testcase_13 AC 120 ms
10,180 KB
testcase_14 AC 123 ms
10,180 KB
testcase_15 AC 35 ms
10,180 KB
testcase_16 AC 83 ms
10,180 KB
testcase_17 AC 32 ms
10,180 KB
testcase_18 AC 60 ms
10,180 KB
testcase_19 AC 166 ms
10,180 KB
testcase_20 AC 70 ms
10,180 KB
testcase_21 AC 141 ms
10,180 KB
testcase_22 AC 159 ms
10,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd


def lcm(a, b):
    return a // gcd(a, b) * 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 + 1):
        p = a * y1 + x1
        if p % y2 == x2:
            for b in range(1 if p == 0 else 0, y3 + 1):
                q = b * lcm12 + p
                if q % y3 == x3:
                    print(q)
                    return
            break
    print(-1)


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