結果

問題 No.186 中華風 (Easy)
ユーザー karankaranrankarankaranran
提出日時 2023-01-22 02:55:14
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 632 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 79,060 KB
最終ジャッジ日時 2023-09-06 13:19:08
合計ジャッジ時間 3,174 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,100 KB
testcase_01 AC 71 ms
71,552 KB
testcase_02 AC 76 ms
71,028 KB
testcase_03 AC 75 ms
71,096 KB
testcase_04 AC 75 ms
71,204 KB
testcase_05 AC 73 ms
71,300 KB
testcase_06 AC 73 ms
71,260 KB
testcase_07 AC 74 ms
71,280 KB
testcase_08 AC 74 ms
71,204 KB
testcase_09 AC 71 ms
71,220 KB
testcase_10 AC 71 ms
71,312 KB
testcase_11 AC 71 ms
71,340 KB
testcase_12 AC 71 ms
71,276 KB
testcase_13 AC 71 ms
71,496 KB
testcase_14 AC 72 ms
71,260 KB
testcase_15 AC 72 ms
71,268 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 72 ms
71,260 KB
testcase_19 AC 71 ms
71,424 KB
testcase_20 AC 72 ms
71,100 KB
testcase_21 AC 72 ms
71,176 KB
testcase_22 AC 71 ms
71,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ls = [tuple(map(int,input().split())) for _ in range(3)]

def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a % b)
        y -= (a // b) * x
        return d, x, y
    return a, 1, 0

# V = [(X_i, Y_i), ...]: X_i (mod Y_i)
def remainder(V):
    x = 0; d = 1
    for X, Y in V:
        g, a, b = extgcd(d, Y)
        if (X-x)%g:
            return -1,-1 # 理屈は分からんが駄目な時にこれを出力
        x, d = (Y*b*x + d*a*X) // g, d*(Y // g)
        x %= d
        if x == 0:
            return d
    return x, d # 数字≡x(mod d)ならいいという情報? 最小の数字はx

print(remainder(ls)[0])
0