結果

問題 No.186 中華風 (Easy)
ユーザー karankaranrankarankaranran
提出日時 2023-01-22 02:55:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 71,520 KB
最終ジャッジ日時 2023-09-06 13:19:37
合計ジャッジ時間 2,761 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,324 KB
testcase_01 AC 64 ms
71,100 KB
testcase_02 AC 63 ms
71,324 KB
testcase_03 AC 65 ms
71,484 KB
testcase_04 AC 69 ms
71,388 KB
testcase_05 AC 63 ms
71,016 KB
testcase_06 AC 63 ms
71,260 KB
testcase_07 AC 64 ms
71,220 KB
testcase_08 AC 66 ms
71,476 KB
testcase_09 AC 65 ms
71,108 KB
testcase_10 AC 61 ms
71,260 KB
testcase_11 AC 62 ms
71,504 KB
testcase_12 AC 62 ms
71,112 KB
testcase_13 AC 63 ms
71,308 KB
testcase_14 AC 64 ms
71,112 KB
testcase_15 AC 67 ms
71,108 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 63 ms
71,280 KB
testcase_19 AC 65 ms
71,228 KB
testcase_20 AC 65 ms
71,252 KB
testcase_21 AC 63 ms
71,340 KB
testcase_22 AC 64 ms
70,976 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,d
    return x, d # 数字≡x(mod d)ならいいという情報? 最小の数字はx

print(remainder(ls)[0])
0