結果

問題 No.186 中華風 (Easy)
ユーザー brthyyjpbrthyyjp
提出日時 2020-04-26 20:26:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 71,604 KB
最終ジャッジ日時 2023-08-11 14:22:58
合計ジャッジ時間 3,226 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,388 KB
testcase_01 AC 67 ms
71,420 KB
testcase_02 AC 65 ms
71,052 KB
testcase_03 AC 67 ms
71,496 KB
testcase_04 AC 64 ms
71,308 KB
testcase_05 AC 66 ms
71,200 KB
testcase_06 AC 64 ms
71,420 KB
testcase_07 AC 65 ms
71,304 KB
testcase_08 AC 67 ms
71,272 KB
testcase_09 AC 66 ms
71,264 KB
testcase_10 AC 65 ms
71,244 KB
testcase_11 AC 66 ms
71,428 KB
testcase_12 AC 68 ms
71,308 KB
testcase_13 AC 66 ms
70,996 KB
testcase_14 AC 67 ms
71,424 KB
testcase_15 AC 67 ms
71,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 66 ms
71,380 KB
testcase_19 AC 67 ms
71,344 KB
testcase_20 AC 67 ms
71,044 KB
testcase_21 AC 67 ms
71,280 KB
testcase_22 AC 65 ms
71,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def extgcd(a, b):
    if b == 0:
        return 1, 0, a
    q, r = divmod(a, b)
    x, y, d = extgcd(b, r)
    s, t = y, x-q*y
    return s, t, d

def mod(a, m):
    return (a%m + m)%m;

def CRT_list(b, m):
    #b: list
    #m: lsit
    r, M = 0, 1
    for i in range(len(b)):
        p, q, d = extgcd(M, m[i])
        if (b[i]-r)%d != 0:
            return 0, -1
        temp = (b[i]-r)//d * p % (m[i]//d)
        r += M * temp
        M *= m[i]//d
    return mod(r, M), M

X = []
Y = []
for i in range(3):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
#print(extgcd(1, 20))
r, M = CRT_list(X, Y)
#print(r, M)
if M == -1:
    print(-1)
else:
    print(r)
0