結果

問題 No.186 中華風 (Easy)
ユーザー brthyyjpbrthyyjp
提出日時 2020-04-26 20:26:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 52,740 KB
最終ジャッジ日時 2024-04-29 06:39:27
合計ジャッジ時間 2,008 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,352 KB
testcase_01 AC 34 ms
51,968 KB
testcase_02 AC 33 ms
52,096 KB
testcase_03 AC 32 ms
52,096 KB
testcase_04 AC 34 ms
52,096 KB
testcase_05 AC 31 ms
52,272 KB
testcase_06 AC 31 ms
52,352 KB
testcase_07 AC 31 ms
52,352 KB
testcase_08 AC 30 ms
51,712 KB
testcase_09 AC 31 ms
52,096 KB
testcase_10 AC 33 ms
51,968 KB
testcase_11 AC 30 ms
51,840 KB
testcase_12 AC 32 ms
51,968 KB
testcase_13 AC 32 ms
52,352 KB
testcase_14 AC 32 ms
51,968 KB
testcase_15 AC 33 ms
52,352 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 30 ms
51,840 KB
testcase_19 AC 31 ms
51,968 KB
testcase_20 AC 30 ms
52,096 KB
testcase_21 AC 30 ms
51,712 KB
testcase_22 AC 30 ms
52,096 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